From 2fc101d07e0f60a50af84d44a3a8fcce42abf111 Mon Sep 17 00:00:00 2001 From: Wang Shidong <wsdjeg@outlook.com> Date: Sun, 16 May 2021 17:49:10 +0800 Subject: [PATCH] Fix P key binding in defx (#4207) --- config/plugins/defx.vim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/config/plugins/defx.vim b/config/plugins/defx.vim index fe7a52271..86f934fd8 100644 --- a/config/plugins/defx.vim +++ b/config/plugins/defx.vim @@ -272,6 +272,9 @@ function! s:DefxPasteFile(_) abort let path = fnamemodify(path, ':p:h') endif + " If you have xclip-pastefile in your PATH. + " this command will be run on action directory + " support paste file which is copied outside of vim. if executable('xclip-pastefile') let old_wd = getcwd() if old_wd == path @@ -281,11 +284,19 @@ function! s:DefxPasteFile(_) abort call s:VCOP.systemlist(['xclip-pastefile']) noautocmd exe 'cd' fnameescape(old_wd) endif - elseif s:SYS.isWindows && !empty(s:copyed_file_path) + return + endif + + if s:SYS.isWindows && !empty(s:copyed_file_path) " in windows, use copy command for paste file. let destination = path . s:FILE.separator . fnamemodify(s:copyed_file_path, ':t') let cmd = 'cmd /c copy ' . shellescape(s:copyed_file_path) . ' ' . shellescape(destination) call s:VCOP.systemlist(cmd) + elseif !s:SYS.isWindows && !empty(s:copyed_file_path) + " in Linux or MacOS, use cp command for paste file. + let destination = path . s:FILE.separator . fnamemodify(s:copyed_file_path, ':t') + let cmd = 'cp -r ' . shellescape(s:copyed_file_path) . ' ' . shellescape(destination) + call s:VCOP.systemlist(cmd) endif if v:shell_error echohl WarningMsg