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 DocumentCommentProvider edit and delete #59278

Closed
3 tasks done
RMacfarlane opened this issue Sep 25, 2018 · 3 comments
Closed
3 tasks done

Test DocumentCommentProvider edit and delete #59278

RMacfarlane opened this issue Sep 25, 2018 · 3 comments

Comments

@RMacfarlane
Copy link
Contributor

RMacfarlane commented Sep 25, 2018

#58078

Complexity: 4

DocumentCommentProviders now expose a way to edit and delete comments. When the provider has editComment or deleteComment methods and a comment within a document has the canEdit or canDelete flag set, an action bar should appear on hover or focus of the comment. Things to test:

  • Is documentation clear?
  • The action bar for comments shows up at appropriate times
  • UI for edit and delete behave as expected
  • throwing within editComment and deleteComment is safely handled by VSCode
@mjbvz mjbvz added this to the September 2018 milestone Sep 25, 2018
@mjbvz mjbvz assigned dbaeumer, chrmarti, sandy081 and octref and unassigned dbaeumer Sep 25, 2018
@sandy081 sandy081 assigned aeschli and unassigned octref Sep 25, 2018
@sandy081
Copy link
Member

sandy081 commented Sep 25, 2018

@RMacfarlane Is there a sample that can be followed? Otherwise It's unclear where and how to start.

@chrmarti
Copy link
Contributor

@sandy081 I implemented a DocumentCommentProvider from the proposed API.

@RMacfarlane
Copy link
Contributor Author

@sandy081 I haven't made a sample yet since this is still proposed API, but here's a comment provider that provides a comment on the first line of any document

export function activate(context: vscode.ExtensionContext) {
    const _onDidChangeDocumentCommentThreads = new vscode.EventEmitter<vscode.CommentThreadChangedEvent>();

    vscode.workspace.registerDocumentCommentProvider({
        onDidChangeCommentThreads: _onDidChangeDocumentCommentThreads.event,
        provideDocumentComments: async (document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.CommentInfo> => {
            return {
                threads: [{
                    threadId: '1',
                    resource: document.uri,
                    range: new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 0)),
                    comments: [{
                        commentId: '1',
                        body: new vscode.MarkdownString('hello world'),
                        userName: 'me',
                        gravatar: ''
                    }]
                }],
                commentingRanges: []
            }
        },
        createNewCommentThread: async (document: vscode.TextDocument, range: vscode.Range, text: string) => {
            throw new Error('Not implemented');
        },
        replyToCommentThread: async (document: vscode.TextDocument, range: vscode.Range, thread: vscode.CommentThread, text: string) => {
            throw new Error('Not implemented');
        }
    });
}

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

No branches or pull requests

7 participants