diff --git a/kittens/dnd/drop.go b/kittens/dnd/drop.go index ce99b365a..ee75c9603 100644 --- a/kittens/dnd/drop.go +++ b/kittens/dnd/drop.go @@ -535,6 +535,7 @@ func (dnd *dnd) all_mime_data_dropped() (err error) { var c *remote_dir_entry if x == "" { c = &remote_dir_entry{} + drop_status.root_remote_dir.num_children_finished++ } else { name := filepath.Base(x) if !dnd.is_case_sensitive_filesystem { @@ -696,7 +697,9 @@ func (dnd *dnd) on_remote_drop_data(cmd DC) (err error) { dnd.data_request_completed() if parent.num_children_finished >= len(parent.children) { // parent is finished drop_status.open_remote_dir = nil - parent.base_dir = parent.base_dir.unref() + if parent.base_dir != nil { + parent.base_dir = parent.base_dir.unref() + } if parent.item_type != 0 { dnd.lp.QueueDnDData(DC{Type: 'r', Yp: parent.item_type}) // close directory in terminal } @@ -709,7 +712,9 @@ func (dnd *dnd) on_remote_drop_data(cmd DC) (err error) { } } if !is_pending { - c.base_dir = c.base_dir.unref() + if c.base_dir != nil { + c.base_dir = c.base_dir.unref() + } } } if len(drop_status.pending_remote_dirs) > 0 { diff --git a/kitty/dnd.c b/kitty/dnd.c index 65f63cc32..d184a0f99 100644 --- a/kitty/dnd.c +++ b/kitty/dnd.c @@ -518,8 +518,11 @@ drop_operation_to_enum(uint32_t op) { } } +static GLFWDragOperationType last_drop_finish_operation = GLFW_DRAG_OPERATION_NONE; + void drop_set_status(Window *w, int operation, const char *payload, size_t payload_sz, bool more) { + last_drop_finish_operation = GLFW_DRAG_OPERATION_NONE; if (!w->drop.accept_in_progress) { drop_free_accepted_mimes(w); w->drop.accept_in_progress = true; w->drop.accepted_operation = drop_operation_to_enum(operation); @@ -1148,8 +1151,6 @@ drop_process_queue(Window *w) { } } -static GLFWDragOperationType last_drop_finish_operation = GLFW_DRAG_OPERATION_NONE; - void drop_enqueue_request(Window *w, int32_t cell_x, int32_t cell_y, int32_t pixel_y, uint32_t operation) { if (cell_x == 0 && cell_y == 0 && pixel_y == 0) { // drop finished diff --git a/kitty_tests/dnd_kitten.py b/kitty_tests/dnd_kitten.py index cbd1c6e48..49e564dfe 100644 --- a/kitty_tests/dnd_kitten.py +++ b/kitty_tests/dnd_kitten.py @@ -44,9 +44,9 @@ def create_fs(base): f.write(b'x' * sz) os.makedirs(join('d1', 'sd', 'ssd')) os.mkdir(join('d2')) - os.symlink('/' + str(uuid.uuid4()), join('s1')) + os.symlink('/' + str(uuid.uuid4()), join('s1')) # non-existent os.symlink('d1', join('sd')) - os.symlink('/', join('sr')) + os.symlink('/', join('d1', 'sa')) # absolute symlink in sub dir os.symlink('../d1', join('d1', 'sr')) w(4096 * 3 + 113, 'some-image.png') w(0, 'd1', 'f1') @@ -190,9 +190,11 @@ class TestDnDKitten(BaseTest): def test_dnd_kitten_drop(self): img_drop_path = 'images/image.png' self.finish_setup(cli_args=(f'--drop=image/png:{img_drop_path}',)) - self.dnd_kitten_drop(False, img_drop_path) + with self.subTest(remote=False): + self.dnd_kitten_drop(False, img_drop_path) self.reset_kitten(True) - self.dnd_kitten_drop(True, img_drop_path) + with self.subTest(remote=True): + self.dnd_kitten_drop(True, img_drop_path) self.exit_kitten() def dnd_kitten_drop(self, remote_client, img_drop_path): @@ -262,14 +264,9 @@ class TestDnDKitten(BaseTest): jn = os.path.join self.assert_files_have_same_content(jn(self.src_data_dir, 'some-image.png'), jn(self.kitten_wd, img_drop_path)) shutil.rmtree(os.path.dirname(jn(self.kitten_wd, img_drop_path))) - if remote_client: - # TODO: need to send data for the items in the uri list based on - # current data requests using wait_for_state() to handle data - # requests as they arrive. - pass - else: - self.wait_for_state('last_drop_action', GLFW_DRAG_OPERATION_COPY) - self.wait_for_state('drop_action', 0) + self.wait_for_state('last_drop_action', GLFW_DRAG_OPERATION_COPY) + self.wait_for_state('drop_action', 0) + # self.assert_trees_equal(self.src_data_dir, self.kitten_wd) def assert_files_have_same_content(self, a, b): with open(a, 'rb') as fa, open(b, 'rb') as fb: