Skip to content

Commit

Permalink
fix(highlight): only support equal or less than 8 lines (#2988)
Browse files Browse the repository at this point in the history
from documentation of matchaddpos:
    The maximum number of positions is 8.

invoke matchaddpos repeatedly to solve this issue
  • Loading branch information
kevinhwang91 authored Mar 29, 2021
1 parent f27af73 commit 3d31bd6
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions autoload/coc/highlight.vim
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function! coc#highlight#match_ranges(winid, bufnr, ranges, hlGroup, priority) ab
endif
let ids = []
for range in a:ranges
let list = []
let pos = []
let start = range['start']
let end = range['end']
for lnum in range(start['line'] + 1, end['line'] + 1)
Expand All @@ -189,12 +189,25 @@ function! coc#highlight#match_ranges(winid, bufnr, ranges, hlGroup, priority) ab
if colStart == colEnd
continue
endif
call add(list, [lnum, colStart, colEnd - colStart])
call add(pos, [lnum, colStart, colEnd - colStart])
endfor
if !empty(list)
if !empty(pos)
let opts = s:clear_match_by_window ? {'window': a:winid} : {}
let id = matchaddpos(a:hlGroup, list, a:priority, -1, opts)
call add(ids, id)
let i = 1
let l = []
for p in pos
call add(l, p)
if i % 8 == 0
let id = matchaddpos(a:hlGroup, l, a:priority, -1, opts)
call add(ids, id)
let l = []
endif
let i += 1
endfor
if !empty(l)
let id = matchaddpos(a:hlGroup, l, a:priority, -1, opts)
call add(ids, id)
endif
endif
endfor
if !s:clear_match_by_window
Expand Down

0 comments on commit 3d31bd6

Please sign in to comment.