Skip to content

Commit aed4e49

Browse files
authored
fix(apply_icons): filename may be truncated #243
Problem: dirvish#add_icon_fn() may truncate filenames from the left, when icons are being applied. To see the issue, create files 'abc-file.txt', 'defg-file.txt', and 'file.txt' in a directory and display them in a dirvish buffer. All filenames display as 'file.txt'. The problem seems to occur when the basename of one of the files in the directory matches the right-hand portion of one or more other filenames in the same directory. However, experimentation shows that it does not always happen in this case. Solution: Define each pattern to match an exact line.
1 parent babbf69 commit aed4e49

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

autoload/dirvish.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,9 @@ func! s:apply_icons() abort
421421
return
422422
endif
423423
highlight clear Conceal
424+
let i = 0
424425
for f in getline(1, '$')
426+
let i += 1
425427
let icon = ''
426428
for id in sort(keys(s:cb_map))
427429
let icon = s:cb_map[id](f)
@@ -433,7 +435,7 @@ func! s:apply_icons() abort
433435
let isdir = (f[-1:] == s:sep)
434436
let f = substitute(s:f(f), escape(s:sep,'\').'$', '', 'g') " Full path, trim slash.
435437
let tail_esc = escape(fnamemodify(f,':t').(isdir?(s:sep):''), '[,*.^$~\')
436-
exe 'syntax match DirvishColumnHead =^.\{-}\ze'.tail_esc.'$= conceal cchar='.icon
438+
exe 'syntax match DirvishColumnHead =\%'.i.'l^.\{-}\ze'.tail_esc.'$= conceal cchar='.icon
437439
endif
438440
endfor
439441
endf

0 commit comments

Comments
 (0)