From 247ac6df59a89449da536cbe1bbd103692efa8ba Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 May 2026 21:49:42 +0530 Subject: [PATCH] Drag source delete on drop should only be done for remote drops --- kittens/dnd/drag.go | 3 ++- kittens/dnd/main.py | 3 ++- kitty_tests/dnd_kitten.py | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/kittens/dnd/drag.go b/kittens/dnd/drag.go index 3a1752f57..b14d69439 100644 --- a/kittens/dnd/drag.go +++ b/kittens/dnd/drag.go @@ -230,11 +230,12 @@ func (dnd *dnd) on_drag_event(x, y, operation, Y int) (err error) { case 4: was_dropped := dnd.drag_status.dropped was_move := dnd.drag_status.accepted_operation == 2 + was_remote := dnd.drag_status.remote_data_was_sent dnd.reset_drag() if was_dropped && dnd.has_exit_on("drag-finish") { dnd.lp.Quit(0) } - if was_dropped && was_move { + if was_dropped && was_move && was_remote { if ds := dnd.drag_sources["text/uri-list"]; ds != nil { for _, item := range ds.uri_list { if item.metadata.IsDir() { diff --git a/kittens/dnd/main.py b/kittens/dnd/main.py index 8e76ac554..1cd5b56d2 100644 --- a/kittens/dnd/main.py +++ b/kittens/dnd/main.py @@ -69,7 +69,8 @@ They will be dragged as the text/uri-list MIME type which can then be dropped in file manager or similar program to copy the files. If the text/uri-list MIME type is dropped onto this window, the files and directories in it are -copied into the current working directory. +copied into the current working directory. When dragging from this window, if a move operation is +performed when dropping and the drop is to a remote machine, the files and directories to drag and deleted. If data is present on STDIN it is set as text/plain when dragging, unless text/plain is specified via --drag. Any text/plain data that is dropped onto this window is output to STDOUT, if STDOUT is connected to a file, otherwise it diff --git a/kitty_tests/dnd_kitten.py b/kitty_tests/dnd_kitten.py index 0e5da1aae..c8fcf4f65 100644 --- a/kitty_tests/dnd_kitten.py +++ b/kitty_tests/dnd_kitten.py @@ -461,7 +461,8 @@ class TestDnDKitten(BaseTest): self.assert_files_have_same_content(expected, actual) src_items_before = set(os.listdir(self.src_data_dir)) end_drag(False) - # After a move drag finishes, all source files from text/uri-list should be deleted - for name in src_items_before: - item_path = os.path.join(self.src_data_dir, name) - self.assertFalse(os.path.lexists(item_path), f'move drag: {name} should have been deleted from source') + if remote_client: + # After a move drag finishes, all source files from text/uri-list should be deleted + for name in src_items_before: + item_path = os.path.join(self.src_data_dir, name) + self.assertFalse(os.path.lexists(item_path), f'move drag: {name} should have been deleted from source')