Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test file level comments API #238878

Closed
2 tasks done
alexr00 opened this issue Jan 27, 2025 · 0 comments
Closed
2 tasks done

Test file level comments API #238878

alexr00 opened this issue Jan 27, 2025 · 0 comments

Comments

@alexr00
Copy link
Member

alexr00 commented Jan 27, 2025

Refs: #214327

Complexity: 5

Create Issue


A commenting range provider can indicate that file level comments are supported:

vscode/src/vscode-dts/vscode.d.ts

Lines 17290 to 17304 in 18daae3

/**
* The ranges a CommentingRangeProvider enables commenting on.
*/
export interface CommentingRanges {
/**
* Enables comments to be added to a file without a specific range.
*/
enableFileComments: boolean;
/**
* The ranges which allow new comment threads creation.
*/
ranges?: Range[];
}

A comment thread can indicate that a thread is at the file level:

vscode/src/vscode-dts/vscode.d.ts

Lines 17116 to 17121 in 18daae3

/**
* The range the comment thread is located within the document. The thread icon will be shown
* at the last line of the range. When set to undefined, the comment will be associated with the
* file, and not a specific range.
*/
range: Range | undefined;

Using this newly finalized API, you can adapt the comment sample to support file level comments.

First, you'll need to update the commenting range provider to use the enableFileComments option:

https://github.com/microsoft/vscode-extension-samples/blob/0d2044ef630c42b95bcd8d60395f6250a1fe0657/comment-sample/src/extension.ts#L27-L32

There is no default entry point for a user to add a file level comment, so you'll need to add a command for it that calls the addComment command:

vscode.commands.executeCommand('workbench.action.addComment', { fileComment: true });

Verify that the inline documentation for the API makes sense.
Verify that you can use the API to enable file level comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants