Skip to content

Commit

Permalink
fix(handler): correct current winid
Browse files Browse the repository at this point in the history
Closes #5116
  • Loading branch information
fannheyward committed Aug 27, 2024
1 parent aabfc23 commit 457b8cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions autoload/coc/window.vim
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ function! coc#window#close(winid) abort
endif
endfunction

function! coc#window#visible_range(bufnr) abort
let winid = bufwinid(a:bufnr)
if winid == -1
function! coc#window#visible_range() abort
let winid = win_getid()
if winid == 0
return v:null
endif
let info = getwininfo(winid)[0]
Expand Down
2 changes: 1 addition & 1 deletion src/handler/inlayHint/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default class InlayHintBuffer implements SyncItem {
if ((events.insertMode && !this.config.refreshOnInsertMode) || !this.enabled) return
this.tokenSource = new CancellationTokenSource()
let token = this.tokenSource.token
let res = await this.nvim.call('coc#window#visible_range', [this.doc.bufnr]) as [number, number]
let res = await this.nvim.call('coc#window#visible_range') as [number, number]
if (!Array.isArray(res) || res[1] <= 0 || token.isCancellationRequested) return
if (!srcId) srcId = await this.nvim.createNamespace('coc-inlayHint')
if (token.isCancellationRequested || this.regions.has(res[0], res[1])) return
Expand Down
2 changes: 1 addition & 1 deletion src/handler/semanticTokens/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ export default class SemanticTokensBuffer implements SyncItem {
*/
public async requestRangeHighlights(token: CancellationToken): Promise<RangeHighlights | null> {
let { nvim, doc } = this
let region = await nvim.call('coc#window#visible_range', [this.bufnr]) as [number, number]
let region = await nvim.call('coc#window#visible_range') as [number, number]
if (!region || token.isCancellationRequested) return null
let endLine = Math.min(region[0] + workspace.env.lines * 2, region[1] + workspace.env.lines, doc.lineCount)
let range = Range.create(region[0] - 1, 0, endLine, 0)
Expand Down

0 comments on commit 457b8cd

Please sign in to comment.