Skip to content

Commit 03f814f

Browse files
xuanduc987chemzqm
authored andcommitted
fix: duplicated diagnostics after undo (#2280)
1 parent 9b81574 commit 03f814f

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

autoload/coc/api.vim

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,14 @@ function! s:funcs.buf_add_highlight(bufnr, srcId, hlGroup, line, colStart, colEn
244244
return
245245
endif
246246
let bufnr = a:bufnr == 0 ? bufnr('%') : a:bufnr
247-
let key = 'Coc'.a:hlGroup
248-
if empty(prop_type_get(key))
249-
call prop_type_add(key, {'highlight': a:hlGroup, 'combine': 1})
247+
let key = 'Coc'.a:hlGroup.(a:srcId != -1 ? a:srcId : '')
248+
if empty(prop_type_get(key, {'bufnr': a:bufnr}))
249+
call prop_type_add(key, {'highlight': a:hlGroup, 'combine': 1, 'bufnr': a:bufnr})
250+
if a:srcId != -1
251+
let cached = getbufvar(bufnr, 'prop_namespace_'.a:srcId, [])
252+
call add(cached, key)
253+
call setbufvar(bufnr, 'prop_namespace_'.a:srcId, cached)
254+
endif
250255
endif
251256
let total = strlen(getbufline(bufnr, a:line + 1)[0])
252257
let end = a:colEnd
@@ -258,14 +263,8 @@ function! s:funcs.buf_add_highlight(bufnr, srcId, hlGroup, line, colStart, colEn
258263
if end <= a:colStart
259264
return
260265
endif
261-
let id = 0
262-
if a:srcId != -1
263-
let cached = getbufvar(bufnr, 'prop_namespace_'.a:srcId, [])
264-
let id = s:prop_id
265-
let s:prop_id = id + 1
266-
call add(cached, id)
267-
call setbufvar(bufnr, 'prop_namespace_'.a:srcId, cached)
268-
endif
266+
let id = s:prop_id
267+
let s:prop_id = id + 1
269268
try
270269
call prop_add(a:line + 1, a:colStart + 1, {'length': end - a:colStart, 'bufnr': bufnr, 'type': key, 'id': id})
271270
catch /^Vim\%((\a\+)\)\=:E967/
@@ -288,19 +287,8 @@ function! s:funcs.buf_clear_namespace(bufnr, srcId, startLine, endLine) abort
288287
if empty(cached)
289288
return
290289
endif
291-
call setbufvar(a:bufnr, 'prop_namespace_'.a:srcId, [])
292-
for id in cached
293-
if a:endLine == -1
294-
if a:startLine == 0 && a:endLine == -1
295-
call prop_remove({'id':id, 'bufnr': a:bufnr})
296-
elseif a:endLine != -1
297-
call prop_remove({'id':id, 'bufnr': a:bufnr}, a:startLine, a:endLine)
298-
else
299-
let len = s:buf_line_count(a:bufnr)
300-
call prop_remove({'id':id, 'bufnr': a:bufnr}, a:startLine, len)
301-
endif
302-
else
303-
endif
290+
for key in cached
291+
call prop_remove({'type': key, 'bufnr': a:bufnr, 'all': 1})
304292
endfor
305293
endif
306294
endfunction

build/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23686,7 +23686,7 @@ class Plugin extends events_1.EventEmitter {
2368623686
});
2368723687
}
2368823688
get version() {
23689-
return workspace_1.default.version + ( true ? '-' + "1bf7e5334e" : undefined);
23689+
return workspace_1.default.version + ( true ? '-' + "e4ab88cd5d" : undefined);
2369023690
}
2369123691
hasAction(method) {
2369223692
return this.actions.has(method);

0 commit comments

Comments
 (0)