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

Other properties in the returned comment are dummy while edit comment #59460

Closed
sandy081 opened this issue Sep 26, 2018 · 1 comment
Closed
Assignees

Comments

@sandy081
Copy link
Member

Testing #59278

'use strict';
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
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: '',
                        canEdit: true,
                        canDelete: true
                    }]
                }],
                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');
        },
        editComment: async (document: vscode.TextDocument, comment: vscode.Comment, text: string, token: vscode.CancellationToken) => {

            return {
                commentId: '10',
                body: new vscode.MarkdownString(text),
                userName: 'me',
                gravatar: '',
                canEdit: false,
                canDelete: false
            };
        },
        deleteComment: async (document: vscode.TextDocument, comment: vscode.Comment, token: vscode.CancellationToken) => {
            return null;
        }
    });
}

// this method is called when your extension is deactivated
export function deactivate() {
}

In editComment, I am returning a comment that does not support edit and delete. This is not being considered. Also setting commentId (may be other properties) does not have impact. If they are not considered we should not return the comment instead updated text?

@RMacfarlane
Copy link
Contributor

Ah, good point. I'm going to change the return type to Promise<void>, since the core already has the updated text, it doesn't actually need anything back from the extension.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants