aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2024-07-30 21:41:40 +0200
committerChristian Clason <c.clason@uni-graz.at>2024-07-31 00:19:03 +0200
commit617810d72d78ce7e1f5e6b6e71ccb6bb5960904d (patch)
treec3956ef3b857a7c3e9afb7dfbab22ae25074bc62
parentbd6bef60ba722cf489aa6b2a4e3c901a899075ba (diff)
downloadrneovim-617810d72d78ce7e1f5e6b6e71ccb6bb5960904d.tar.gz
rneovim-617810d72d78ce7e1f5e6b6e71ccb6bb5960904d.tar.bz2
rneovim-617810d72d78ce7e1f5e6b6e71ccb6bb5960904d.zip
vim-patch:e34d0e3: runtime(netrw): removing trailing slash when copying files in same directory
closes: vim/vim#14756 https://github.com/vim/vim/commit/e34d0e37e397419636ae5d27d4b236b193efef07 Co-authored-by: Travis Shelton <tshelton.mail@gmail.com>
-rw-r--r--runtime/autoload/netrw.vim16
1 files changed, 13 insertions, 3 deletions
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
index 92d8409440..44088f3b7f 100644
--- a/runtime/autoload/netrw.vim
+++ b/runtime/autoload/netrw.vim
@@ -3,7 +3,7 @@
" Maintainer: This runtime file is looking for a new maintainer.
" Date: May 03, 2023
" Version: 173a
-" Last Change:
+" Last Change: {{{1
" 2023 Nov 21 by Vim Project: ignore wildignore when expanding $COMSPEC (v173a)
" 2023 Nov 22 by Vim Project: fix handling of very long filename on longlist style (v173a)
" 2024 Feb 19 by Vim Project: (announce adoption)
@@ -18,6 +18,8 @@
" 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077, #15114)
" 2024 Jul 22 by Vim Project: avoid endless recursion (#15318)
" 2024 Jul 23 by Vim Project: escape filename before trying to delete it (#15330)
+" 2024 Jul 30 by Vim Project: handle mark-copy to same target directory (#12112)
+" }}}
" Former Maintainer: Charles E Campbell
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
@@ -7105,7 +7107,7 @@ fun! s:NetrwMarkFileCopy(islocal,...)
endif
" copy marked files while within the same directory (ie. allow renaming)
- if simplify(s:netrwmftgt) == simplify(b:netrw_curdir)
+ if s:StripTrailingSlash(simplify(s:netrwmftgt)) == s:StripTrailingSlash(simplify(b:netrw_curdir))
if len(s:netrwmarkfilelist_{bufnr('%')}) == 1
" only one marked file
" call Decho("case: only one marked file",'~'.expand("<slnum>"))
@@ -7182,7 +7184,7 @@ fun! s:NetrwMarkFileCopy(islocal,...)
" call Decho("system(".copycmd." '".args."' '".tgt."')",'~'.expand("<slnum>"))
call system(copycmd.g:netrw_localcopycmdopt." '".args."' '".tgt."'")
if v:shell_error != 0
- if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir
+ if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && g:netrw_keepdir
call netrw#ErrorMsg(s:ERROR,"copy failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",101)
else
call netrw#ErrorMsg(s:ERROR,"tried using g:netrw_localcopycmd<".g:netrw_localcopycmd.">; it doesn't work!",80)
@@ -11536,6 +11538,14 @@ fun! netrw#WinPath(path)
endfun
" ---------------------------------------------------------------------
+" s:StripTrailingSlash: removes trailing slashes from a path {{{2
+fun! s:StripTrailingSlash(path)
+ " remove trailing slash
+ return substitute(a:path, '[/\\]$', '', 'g')
+endfun
+
+
+" ---------------------------------------------------------------------
" s:NetrwBadd: adds marked files to buffer list or vice versa {{{2
" cb : bl2mf=0 add marked files to buffer list
" cB : bl2mf=1 use bufferlist to mark files