From bfcf5666cc83f1d87fe62ef371ff02e2bbd04bd4 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 29 Feb 2024 18:02:29 +0100 Subject: vim-patch:56b7da3c051f runtime(netrw): handle file/dir symlinks specifically in tree mode fixes: vim/vim#2386 related: vim/vim#3609 https://github.com/vim/vim/commit/56b7da3c051fe1a5fd76534998c17b22d83c0899 Co-authored-by: Christian Brabandt --- runtime/autoload/netrw.vim | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 33d3fbd4cc..363fc660ec 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -9376,7 +9376,7 @@ fun! s:NetrwTreeDir(islocal) " call Decho("treedir<".treedir.">",'~'.expand("")) elseif curline =~ '@$' " call Decho("handle symbolic link from current line",'~'.expand("")) - let treedir= resolve(substitute(substitute(getline('.'),'@.*$','','e'),'^|*\s*','','e')) + let potentialdir= resolve(substitute(substitute(getline('.'),'@.*$','','e'),'^|*\s*','','e')) " call Decho("treedir<".treedir.">",'~'.expand("")) else " call Decho("do not extract tree subdirectory from current line and set treedir to empty",'~'.expand("")) @@ -9401,7 +9401,6 @@ fun! s:NetrwTreeDir(islocal) " call Decho("COMBAK#23 : mod=".&mod." win#".winnr()) " call Decho("islocal=".a:islocal." curline<".curline.">",'~'.expand("")) - let potentialdir= s:NetrwFile(substitute(curline,'^'.s:treedepthstring.'\+ \(.*\)@$','\1','')) " call Decho("potentialdir<".potentialdir."> isdir=".isdirectory(potentialdir),'~'.expand("")) " call Decho("COMBAK#24 : mod=".&mod." win#".winnr()) @@ -9414,8 +9413,15 @@ fun! s:NetrwTreeDir(islocal) " " call Decho("newdir <".newdir.">",'~'.expand("")) " else " call Decho("apply NetrwTreePath to treetop<".w:netrw_treetop.">",'~'.expand("")) - let treedir = s:NetrwTreePath(w:netrw_treetop) -" endif + if a:islocal && curline =~ '@$' + if isdirectory(s:NetrwFile(potentialdir)) + let treedir = w:netrw_treetop.'/'.potentialdir.'/' + let w:netrw_treetop = treedir + endif + else + let potentialdir= s:NetrwFile(substitute(curline,'^'.s:treedepthstring.'\+ \(.*\)@$','\1','')) + let treedir = s:NetrwTreePath(w:netrw_treetop) + endif endif " call Decho("COMBAK#25 : mod=".&mod." win#".winnr()) -- cgit