Skip to content

Commit b97e12d

Browse files
author
Your Name
committed
Call coc#api s:funcs.buf_add_highlight directly
1 parent 70091c9 commit b97e12d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

autoload/coc/api.vim

+7-2
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,12 @@ function! s:funcs.buf_get_mark(bufnr, name)
535535
return [line("'" . a:name), col("'" . a:name) - 1]
536536
endfunction
537537

538-
def s:funcs.buf_add_highlight(bufnr: number, srcId: number, hlGroup: string, line: number, colStart: number, colEnd: number, ...list: list<dict<any>>): any
538+
def s:funcs.buf_add_highlight(bufnr: number, srcId: number, hlGroup: string, line: number, colStart: number, colEnd: number, ...optionalArguments: list<dict<any>>): any
539+
const opts: dict<any> = get(optionalArguments, 0, {})
540+
return coc#api#funcs_buf_add_highlight(bufnr, src_id, hl_group, line, col_start, col_end, opts)
541+
enddef
542+
" To be called directly for performance reason
543+
def coc#api#funcs_buf_add_highlight(bufnr: number, srcId: number, hlGroup: string, line: number, colStart: number, colEnd: number, propTypeOpts: dict<any> = {}): any
539544
var sourceId: number
540545
if srcId == 0
541546
sourceId = s:max_src_id + 1
@@ -550,7 +555,7 @@ def s:funcs.buf_add_highlight(bufnr: number, srcId: number, hlGroup: string, lin
550555
add(propTypes, propType)
551556
s:id_types[srcId] = propTypes
552557
if empty(prop_type_get(propType))
553-
prop_type_add(propType, extend({'highlight': hlGroup}, get(list, 0, {})))
558+
prop_type_add(propType, extend({'highlight': hlGroup}, propTypeOpts))
554559
endif
555560
endif
556561
const columnEnd: number = colEnd == -1 ? strlen(get(getbufline(bufferNumber, line + 1), 0, '')) + 1 : colEnd + 1

autoload/coc/highlight.vim

+3-3
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,11 @@ if !s:is_vim
673673
" @workaround Prevent nvim running into the branch for vim below
674674
finish
675675
else
676-
def coc#highlight#add_highlight(bufnr: number, src_id: number, hl_group: string, line: number, col_start: number, col_end: number, ...list: list<dict<any>>)
677-
const opts: dict<any> = get(list, 0, {})
676+
def coc#highlight#add_highlight(bufnr: number, src_id: number, hl_group: string, line: number, col_start: number, col_end: number, ...optionalArguments: list<dict<any>>)
677+
const opts: dict<any> = get(optionalArguments, 0, {})
678678
if !hlexists(hl_group)
679679
execute $'highlight {hl_group} ctermfg=NONE'
680680
endif
681-
coc#api#exec('buf_add_highlight', [bufnr, src_id, hl_group, line, col_start, col_end, opts])
681+
coc#api#funcs_buf_add_highlight(bufnr, src_id, hl_group, line, col_start, col_end, opts)
682682
enddef
683683
endif

0 commit comments

Comments
 (0)