Skip to content

Commit b5f8261

Browse files
committed
Highlight only individual characters
1 parent b5d3fe6 commit b5f8261

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

autoload/ctrlp.vim

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,12 +1622,30 @@ fu! s:highlight(pat, grp)
16221622
if s:matcher != {} | retu | en
16231623
cal clearmatches()
16241624
if !empty(a:pat) && s:ispath
1625-
let pat = s:regexp ? substitute(a:pat, '\\\@<!\^', '^> \\zs', 'g') : a:pat
1626-
if s:byfname
1627-
let pat = substitute(pat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g')
1628-
let pat = substitute(pat, '\$\@<!$', '\\ze[^\\/]*$', 'g')
1625+
if s:regexp
1626+
let pat = substitute(a:pat, '\\\@<!\^', '^> \\zs', 'g')
1627+
cal matchadd(a:grp, ( s:martcs == '' ? '\c' : '\C' ).pat)
1628+
el
1629+
let pat = a:pat
1630+
1631+
" calculate how many letters are here
1632+
let lettercount = len(split(pat, '\\{-}'))
1633+
for i in range(lettercount)
1634+
" surround the letter we care about with \zs and \ze so only it is
1635+
" highlighted in this go.
1636+
let letterpat = substitute(pat, '^\%(.\{-}\\{-}\)\{'.i.'}\zs.\{-}\ze\%(\[^.*\)\?$', '\\zs\0\\ze', '')
1637+
1638+
if s:byfname
1639+
" replace [^x] with [^/x] to make sure no slashes between letters
1640+
let letterpat = substitute(letterpat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g')
1641+
" replace the end to make sure no slashes follow the pattern
1642+
let letterpat = substitute(letterpat, '\$\@<!$', '[^\\/]*$', 'g')
1643+
en
1644+
1645+
cal matchadd(a:grp, ( s:martcs == '' ? '\c' : '\C' ).letterpat)
1646+
endfo
16291647
en
1630-
cal matchadd(a:grp, ( s:martcs == '' ? '\c' : '\C' ).pat)
1648+
16311649
cal matchadd('CtrlPLinePre', '^>')
16321650
en
16331651
endf

0 commit comments

Comments
 (0)