How to navigate a comments programmatically? #184
-
Click comment item in the Comments panel will open the target file and navigate to the target comment, is there any way to do it programmatically? The scenario from my side is listed below:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @KrabsWong , To open a file and navigate to some specific position, you must open a file, show it and reveal the position (line - character). Something like: const document = await vscode.workspace.openTextDocument(fileUri);
await vscode.window.showTextDocument(document);
const position = new Selection(line, column, line, column);
window.activeTextEditor.selection = newPosition;
window.activeTextEditor.revealRange(newPosition, reviewType); About the comment itself, I didn't play with it that much, but it seems the BTW, I would suggest you to take a look at the CodeTour extension (https://github.com/microsoft/codetour), which I remember to be a good source of knowledge about the Comments API, as it uses it at its core. Hope this helps |
Beta Was this translation helpful? Give feedback.
Hi @KrabsWong ,
To open a file and navigate to some specific position, you must open a file, show it and reveal the position (line - character). Something like:
About the comment itself, I didn't play with it that much, but it seems the
CommentThread
interface has acollapsibleState
, which defines if the thread must be displayed collapsed/expanded when opened the document.BTW, I would s…