From a4842e19d479867ff83105fb7b6e1af175d25692 Mon Sep 17 00:00:00 2001 From: Christian Zangl Date: Fri, 4 Feb 2022 17:21:03 +0100 Subject: [PATCH] keep copy selections after paste (#745) --- doc.go | 4 ++-- docstring.go | 4 ++-- lf.1 | 4 ++-- nav.go | 23 +++++++++++------------ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/doc.go b/doc.go index c6b0acf1..7f961f5a 100644 --- a/doc.go +++ b/doc.go @@ -1098,9 +1098,9 @@ You can use the following example as a starting point: cp -R $list . elif [ $mode = 'move' ]; then mv $list . + rm ~/.local/share/lf/files + lf -remote 'send clear' fi - rm ~/.local/share/lf/files - lf -remote 'send clear' }} Some useful things to be considered are to use the backup ('--backup') and/or preserve attributes ('-a') options with 'cp' and 'mv' commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use 'rsync' command with progress bar option for copying and feed the progress to the client periodically with remote 'echo' calls. diff --git a/docstring.go b/docstring.go index e7880b53..93926139 100644 --- a/docstring.go +++ b/docstring.go @@ -1215,9 +1215,9 @@ point: cp -R $list . elif [ $mode = 'move' ]; then mv $list . + rm ~/.local/share/lf/files + lf -remote 'send clear' fi - rm ~/.local/share/lf/files - lf -remote 'send clear' }} Some useful things to be considered are to use the backup ('--backup') diff --git a/lf.1 b/lf.1 index 91cbbf09..98576ab7 100644 --- a/lf.1 +++ b/lf.1 @@ -1272,9 +1272,9 @@ You can customize copy and move operations by defining a 'paste' command. This i cp -R $list . elif [ $mode = 'move' ]; then mv $list . + rm ~/.local/share/lf/files + lf -remote 'send clear' fi - rm ~/.local/share/lf/files - lf -remote 'send clear' }} .EE .PP diff --git a/nav.go b/nav.go index 1330b1e5..9df0b922 100644 --- a/nav.go +++ b/nav.go @@ -1043,19 +1043,18 @@ func (nav *nav) paste(ui *ui) error { go nav.copyAsync(ui, srcs, dstDir) } else { go nav.moveAsync(ui, srcs, dstDir) - } - - if err := saveFiles(nil, false); err != nil { - return fmt.Errorf("clearing copy/cut buffer: %s", err) - } - - if gSingleMode { - if err := nav.sync(); err != nil { - return fmt.Errorf("paste: %s", err) + if err := saveFiles(nil, false); err != nil { + return fmt.Errorf("clearing copy/cut buffer: %s", err) } - } else { - if err := remote("send sync"); err != nil { - return fmt.Errorf("paste: %s", err) + + if gSingleMode { + if err := nav.sync(); err != nil { + return fmt.Errorf("paste: %s", err) + } + } else { + if err := remote("send sync"); err != nil { + return fmt.Errorf("paste: %s", err) + } } }