Drag source delete on drop should only be done for remote drops

This commit is contained in:
Kovid Goyal 2026-05-05 21:49:42 +05:30
parent c224fae023
commit 247ac6df59
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 9 additions and 6 deletions

View file

@ -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() {

View file

@ -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

View file

@ -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')