Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix extra conceal characters are shown in label-mode #244

Merged
merged 1 commit into from
Nov 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions autoload/sneak/label.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let g:sneak#target_labels = get(g:, 'sneak#target_labels', ";sftunq/SFGHLTUNRMQZ
let s:clear_syntax = !has('patch-7.4.792')
let s:matchmap = {}
let s:match_ids = []
let s:orig_conceal_matches = []

func! s:placematch(c, pos) abort
let s:matchmap[a:c] = a:pos
Expand All @@ -22,6 +23,25 @@ func! s:placematch(c, pos) abort
endif
endf

func! s:save_conceal_matches() abort
for m in getmatches()
if m.group ==# 'Conceal'
call add(s:orig_conceal_matches, m)
silent! call matchdelete(m.id)
endif
endfor
endf

func! s:restore_conceal_matches() abort
for m in s:orig_conceal_matches
let d = {}
if has_key(m, 'conceal') | let d.conceal = m.conceal | endif
if has_key(m, 'window') | let d.window = m.window | endif
silent! call matchadd(m.group, m.pattern, m.priority, m.id, d)
endfor
let s:orig_conceal_matches = []
endf

func! sneak#label#to(s, v, label) abort
let seq = ""
while 1
Expand Down Expand Up @@ -101,6 +121,7 @@ func! s:after() abort
let s:match_ids = []
"remove temporary highlight links
exec 'hi! link Conceal '.s:orig_hl_conceal
call s:restore_conceal_matches()
exec 'hi! link Sneak '.s:orig_hl_sneak

if s:clear_syntax
Expand Down Expand Up @@ -161,6 +182,7 @@ func! s:before() abort
endif

let s:orig_hl_conceal = sneak#util#links_to('Conceal')
call s:save_conceal_matches()
let s:orig_hl_sneak = sneak#util#links_to('Sneak')
"set temporary link to our custom 'conceal' highlight
hi! link Conceal SneakLabel
Expand Down