update context key

This commit is contained in:
Peng Lyu
2019-05-23 09:21:34 -07:00
parent bc3a287d6a
commit 8d6054d932
3 changed files with 52 additions and 11 deletions

View File

@ -40,8 +40,8 @@ export function activate(context: vscode.ExtensionContext) {
}));
context.subscriptions.push(vscode.commands.registerCommand('mywiki.startDraft', (reply: vscode.CommentReply) => {
vscode.commands.executeCommand('setContext', 'inDraft', true);
let thread = reply.thread;
thread.contextValue = 'draft';
let newComment = new NoteComment(reply.text, vscode.CommentMode.Preview, { name: 'vscode' }, thread);
newComment.label = 'pending';
thread.comments = [...thread.comments, newComment];
@ -51,6 +51,7 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.executeCommand('setContext', 'inDraft', false);
let thread = reply.thread;
thread.collapsibleState = undefined;
let newComment = new NoteComment(reply.text, vscode.CommentMode.Preview, { name: 'vscode' }, thread);
thread.comments = [...thread.comments, newComment].map(comment => {
comment.label = undefined;

View File

@ -70,6 +70,26 @@ declare module 'vscode' {
* The optional human-readable label describing the [Comment Thread](#CommentThread)
*/
label?: string;
/**
* Context value of the comment thread. This can be used to contribute thread specific actions.
* For example, a comment thread is given a context value as `editable`. When contributing actions to `comments/commentThread/title`
* using `menus` extension point, you can specify context value for key `commentThread` in `when` expression like `commentThread == editable`.
* ```
* "contributes": {
* "menus": {
* "comments/commentThread/title": [
* {
* "command": "extension.deleteCommentThread",
* "when": "commentThread == editable"
* }
* ]
* }
* }
* ```
* This will show action `extension.deleteCommentThread` only for comment threads with `contextValue` is `editable`.
*/
contextValue?: string;
/**
* Dispose this comment thread.
@ -115,6 +135,26 @@ declare module 'vscode' {
* Label will be rendered next to authorName if exists.
*/
label?: string;
/**
* Context value of the comment. This can be used to contribute comment specific actions.
* For example, a comment is given a context value as `editable`. When contributing actions to `comments/comment/title`
* using `menus` extension point, you can specify context value for key `comment` in `when` expression like `comment == editable`.
* ```
* "contributes": {
* "menus": {
* "comments/comment/title": [
* {
* "command": "extension.deleteComment",
* "when": "comment == editable"
* }
* ]
* }
* }
* ```
* This will show action `extension.deleteComment` only for comments with `contextValue` is `editable`.
*/
contextValue?: string;
}
export interface CommentReply {