Skip to content

Commit

Permalink
feat(scope): ensureDocument can accept bufnr (#5219)
Browse files Browse the repository at this point in the history
Closes #5218
  • Loading branch information
fannheyward authored Dec 10, 2024
1 parent 28ad86d commit 1e7abfa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions doc/coc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2448,9 +2448,9 @@ Acceptable {action} names for |CocAction()| and |CocActionAsync()|.
Add {folder} to workspace folders, {folder} should be exists directory
on file system.

"ensureDocument" *CocAction('ensureDocument')*
"ensureDocument" [{bufnr}] *CocAction('ensureDocument')*

Ensure current document is attached to coc.nvim
Ensure current or specified document is attached to coc.nvim
|coc-document-attached|, should be used when you need invoke action of
current document on buffer create.

Expand Down
5 changes: 5 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 2024-12-10

- Floating window can be set to fixed position, try `diagnostic.floatConfig`
- `ensureDocument` and `hasProvider` support to accept specified bufnr

# 2024-11-29

- Increase `g:coc_highlight_maximum_count` default to 500 for better performance.
Expand Down
4 changes: 2 additions & 2 deletions src/handler/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ export default class WorkspaceHandler {
}
}

public async ensureDocument(): Promise<boolean> {
let doc = await workspace.document
public async ensureDocument(bufnr?: number): Promise<boolean> {
let doc = bufnr ? workspace.getDocument(bufnr) : await workspace.document
return doc && doc.attached
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class Plugin {
void window.showInformationMessage(`Run :CocInstall coc-json for json intellisense`)
})
this.addAction('rootPatterns', (bufnr: number) => this.handler.workspace.getRootPatterns(bufnr))
this.addAction('ensureDocument', () => this.handler.workspace.ensureDocument())
this.addAction('ensureDocument', (bufnr?: number) => this.handler.workspace.ensureDocument(bufnr))
this.addAction('addWorkspaceFolder', (folder: string) => this.handler.workspace.addWorkspaceFolder(folder))
this.addAction('removeWorkspaceFolder', (folder: string) => this.handler.workspace.removeWorkspaceFolder(folder))
this.addAction('getConfig', (key: string) => this.handler.workspace.getConfiguration(key))
Expand Down

0 comments on commit 1e7abfa

Please sign in to comment.