mirror of
https://github.com/chenasraf/vim-matchup.git
synced 2026-05-18 01:38:57 +00:00
Tweak status_str computation for where
This commit is contained in:
@@ -880,14 +880,14 @@ function! matchup#matchparen#status_str(offscreen, ...) abort " {{{1
|
||||
endif
|
||||
|
||||
if has_key(l:opts, 'width')
|
||||
" TODO subtract the gutter from above
|
||||
let l:room = l:opts.width
|
||||
" TODO subtract the gutter above more accurately
|
||||
let l:room = l:opts.width - (wincol()-virtcol('.'))
|
||||
else
|
||||
let l:room = min([300, winwidth(0)]) - (wincol()-virtcol('.'))
|
||||
endif
|
||||
let l:room -= l:adjust ? 3+strdisplaywidth(a:offscreen.match) : 0
|
||||
let l:lasthi = ''
|
||||
for l:c in range(min([l:room, strlen(l:line)]))
|
||||
for l:c in range(strlen(l:line))
|
||||
if !l:adjust && a:offscreen.cnum <= l:c+1 && l:c+1 <= a:offscreen.cnum
|
||||
\ - 1 + strlen(a:offscreen.match)
|
||||
" TODO: we can't overlap groups, this might not be totally correct
|
||||
@@ -901,16 +901,22 @@ function! matchup#matchparen#status_str(offscreen, ...) abort " {{{1
|
||||
endif
|
||||
endif
|
||||
let l:sl .= (l:curhi !=# l:lasthi ? '%#'.l:curhi.'#' : '')
|
||||
if l:trimming && l:line[l:c] !~ '\s'
|
||||
if l:trimming && l:line[l:c] !~? '\s'
|
||||
let l:trimming = 0
|
||||
endif
|
||||
if !l:trimming
|
||||
let l:room -= 1
|
||||
if l:room <= 0
|
||||
break
|
||||
endif
|
||||
endif
|
||||
if l:trimming
|
||||
elseif l:line[l:c] ==# "\t"
|
||||
let l:sl .= repeat(' ', strdisplaywidth(strpart(l:line, 0, 1+l:c))
|
||||
\ - strdisplaywidth(strpart(l:line, 0, l:c)))
|
||||
elseif char2nr(l:line[l:c]) < 32
|
||||
let l:sl .= strtrans(l:line[l:c])
|
||||
elseif l:line[l:c] == '%'
|
||||
elseif l:line[l:c] ==? '%'
|
||||
let l:sl .= '%%'
|
||||
else
|
||||
let l:sl .= l:line[l:c]
|
||||
|
||||
Reference in New Issue
Block a user