Skip to content

Commit

Permalink
fix(handler): use application scope for debounce time
Browse files Browse the repository at this point in the history
  • Loading branch information
chemzqm committed Sep 29, 2023
1 parent 4992180 commit d1568d5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion data/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@
},
"coc.preferences.currentFunctionSymbolDebounceTime": {
"type": "number",
"scope": "language-overridable",
"scope": "application",
"description": "Set debounce timer for the update of b:coc_current_function on CursorMove event",
"default": 300
},
Expand Down
2 changes: 1 addition & 1 deletion doc/coc-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ Preferences~
Set debounce timer for the update of b:coc_current_function on CursorMove
event

Scope: `language-overridable`, default: `300`
Scope: `application`, default: `300`

"coc.preferences.enableLinkedEditing" *coc-preferences-enableLinkedEditing*

Expand Down
8 changes: 2 additions & 6 deletions src/handler/symbols/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default class Symbols {
return buf
})
this.outline = new Outline(nvim, this.buffers, handler)
const debounceTime = workspace.initialConfiguration.get<number>('coc.preferences.currentFunctionSymbolDebounceTime', 300)
let debounced = debounce(async (bufnr: number, cursor: [number, number]) => {
if (!this.buffers.getItem(bufnr) || !this.autoUpdate(bufnr)) return
let doc = workspace.getDocument(bufnr)
Expand All @@ -46,7 +47,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)
}, this.debounceTime())
}, getConditionValue(debounceTime, 0))
events.on('CursorMoved', debounced, this, this.disposables)
this.disposables.push(Disposable.create(() => {
debounced.clear()
Expand All @@ -63,11 +64,6 @@ export default class Symbols {
return config.get<boolean>('currentFunctionSymbolAutoUpdate', false)
}

public debounceTime(): number {
let config = workspace.getConfiguration('coc.preferences')
return getConditionValue(config.get<number>('currentFunctionSymbolDebounceTime', 300), 0)
}

public get labels(): { [key: string]: string } {
return workspace.getConfiguration('suggest').get<any>('completionItemKindLabels', {})
}
Expand Down

0 comments on commit d1568d5

Please sign in to comment.