@@ -3,6 +3,7 @@ let s:sep = exists('+shellslash') && !&shellslash ? '\' : '/'
33let s: noswapfile = (2 == exists (' :noswapfile' )) ? ' noswapfile' : ' '
44let s: noau = ' silent noautocmd keepjumps'
55let s: cb_map = {} " callback map
6+ let s: rel = get (g: , ' dirvish_relative_paths' , 0 )
67
78" Debug:
89" echo '' > dirvish.log ; tail -F dirvish.log
@@ -22,6 +23,10 @@ func! s:msg_error(msg) abort
2223 redraw | echohl ErrorMsg | echomsg ' dirvish:' a: msg | echohl None
2324endf
2425
26+ func ! s: eq (dir1, dir2) abort
27+ return fnamemodify (a: dir1 , ' :p' ) == # fnamemodify (a: dir2 , ' :p' )
28+ endf
29+
2530func ! s: suf () abort
2631 let m = get (g: , ' dirvish_mode' , 1 )
2732 return type (m ) == type (0 ) && m <= 1 ? 1 : 0
@@ -72,9 +77,8 @@ func! s:list_dir(dir) abort
7277 " Append dot-prefixed files. globpath() cannot do both in 1 pass.
7378 let paths = paths + s: globlist (dir_esc, ' .[^.]*' )
7479
75- if get (g: , ' dirvish_relative_paths' , 0 )
76- \ && a: dir != s: parent_dir (getcwd ()) " avoid blank CWD
77- return map (paths, " fnamemodify(v:val, ':p:.')" )
80+ if s: rel && ! s: eq (a: dir , s: parent_dir (getcwd ()))
81+ return map (paths, " fnamemodify(v:val, ':p:.')" ) " Avoid blank CWD.
7882 else
7983 return map (paths, " fnamemodify(v:val, ':p')" )
8084 endif
@@ -389,7 +393,7 @@ func! s:buf_render(dir, lastpath) abort
389393 endif
390394
391395 if ! empty (a: lastpath )
392- let pat = get ( g: , ' dirvish_relative_paths ' , 0 ) ? fnamemodify (a: lastpath , ' :p:.' ) : a: lastpath
396+ let pat = s: rel ? fnamemodify (a: lastpath , ' :p:.' ) : a: lastpath
393397 let pat = empty (pat) ? a: lastpath : pat " no longer in CWD
394398 call search (' \V\^' .escape (pat, ' \' ).' \$' , ' cw' )
395399 endif
@@ -446,7 +450,7 @@ func! s:open_dir(d, reload) abort
446450 " Use :file to force a normalized path.
447451 " - Avoids ".././..", ".", "./", etc. (breaks %:p, not updated on :cd).
448452 " - Avoids [Scratch] in some cases (":e ~/" on Windows).
449- if s: sl (bufname (' %' )) !=# d ._dir
453+ if ! s: rel && s: sl (bufname (' %' )) !=# d ._dir
450454 execute ' silent ' .s: noswapfile .' file ' . fnameescape (d ._dir)
451455 endif
452456
@@ -500,6 +504,7 @@ func! dirvish#open(...) range abort
500504 return
501505 endif
502506
507+ let s: rel = get (g: , ' dirvish_relative_paths' , 0 )
503508 let d = {}
504509 let is_uri = -1 != match (a: 1 , ' ^\w\+:[\/][\/]' )
505510 let from_path = fnamemodify (bufname (' %' ), ' :p' )
@@ -518,7 +523,7 @@ func! dirvish#open(...) range abort
518523
519524 if reloading
520525 let d .lastpath = ' ' " Do not place cursor when reloading.
521- elseif ! is_uri && d ._dir == # s: parent_dir (from_path)
526+ elseif ! is_uri && s: eq ( d ._dir, s: parent_dir (from_path) )
522527 let d .lastpath = from_path " Save lastpath when navigating _up_.
523528 endif
524529
0 commit comments