diff --git a/data/schema.json b/data/schema.json index 287b1236c84..52b99173515 100644 --- a/data/schema.json +++ b/data/schema.json @@ -532,9 +532,15 @@ "coc.preferences.currentFunctionSymbolAutoUpdate": { "type": "boolean", "scope": "language-overridable", - "description": "Automatically update the value of b:coc_current_function on CursorHold event", + "description": "Automatically update the value of b:coc_current_function on CursorMove event", "default": false }, + "coc.preferences.currentFunctionSymbolDebounceTime": { + "type": "number", + "scope": "language-overridable", + "description": "Set debounce timer for the update of b:coc_current_function on CursorMove event", + "default": 300 + }, "coc.preferences.enableLinkedEditing": { "type": "boolean", "scope": "language-overridable", diff --git a/doc/coc-config.txt b/doc/coc-config.txt index 4d4dcbfdf13..53ace94fbed 100644 --- a/doc/coc-config.txt +++ b/doc/coc-config.txt @@ -1520,11 +1520,18 @@ Preferences~ "coc.preferences.currentFunctionSymbolAutoUpdate" *coc-preferences-currentFunctionSymbolAutoUpdate* - Automatically update the value of b:coc_current_function on CursorHold + Automatically update the value of b:coc_current_function on CursorMove event Scope: `language-overridable`, default: `false` +"coc.preferences.currentFunctionSymbolDebounceTime" *coc-preferences-currentFunctionSymbolDebounceTime* + + Set debounce timer for the update of b:coc_current_function on CursorMove + event + + Scope: `language-overridable`, default: `300` + "coc.preferences.enableLinkedEditing" *coc-preferences-enableLinkedEditing* Enable linked editing support. diff --git a/doc/coc.txt b/doc/coc.txt index 701a909b3a2..ee91f057779 100644 --- a/doc/coc.txt +++ b/doc/coc.txt @@ -1997,7 +1997,8 @@ b:coc_current_function *b:coc_current_function* Function string that current cursor in. Enable |coc-preferences-currentFunctionSymbolAutoUpdate| to update the - value on CursorHold. + value on CursorMove and use |coc-preferences-currentFunctionSymbolDebounceTime| + to set the time to debounce the event. b:coc_cursors_activated *b:coc_cursors_activated* diff --git a/src/handler/symbols/index.ts b/src/handler/symbols/index.ts index fb92809c980..462a8b9e2e2 100644 --- a/src/handler/symbols/index.ts +++ b/src/handler/symbols/index.ts @@ -17,8 +17,6 @@ import SymbolsBuffer from './buffer' import Outline from './outline' import { convertSymbols, SymbolInfo } from './util' -const CURSORMOVE_DEBOUNCE = getConditionValue(300, 0) - export default class Symbols { private buffers: BufferSync private disposables: Disposable[] = [] @@ -48,7 +46,7 @@ export default class Symbols { let buffer = nvim.createBuffer(bufnr) buffer.setVar('coc_current_function', func ?? '', true) this.nvim.call('coc#util#do_autocmd', ['CocStatusChange'], true) - }, CURSORMOVE_DEBOUNCE) + }, this.debounceTime()) events.on('CursorMoved', debounced, this, this.disposables) this.disposables.push(Disposable.create(() => { debounced.clear() @@ -65,6 +63,11 @@ export default class Symbols { return config.get('currentFunctionSymbolAutoUpdate', false) } + public debounceTime(): number { + let config = workspace.getConfiguration('coc.preferences') + return getConditionValue(config.get('currentFunctionSymbolDebounceTime', 300), 0) + } + public get labels(): { [key: string]: string } { return workspace.getConfiguration('suggest').get('completionItemKindLabels', {}) }