From 3cf67b0b7de4cf7cf4c4e169de2c20ed9a6ebc1a Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Tue, 5 Mar 2019 10:03:07 -0800 Subject: [PATCH] exthost types, avoid using enums --- src/vs/workbench/api/node/extHostComments.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/api/node/extHostComments.ts b/src/vs/workbench/api/node/extHostComments.ts index 20a2bc40d6e..ea6fd6480dc 100644 --- a/src/vs/workbench/api/node/extHostComments.ts +++ b/src/vs/workbench/api/node/extHostComments.ts @@ -8,6 +8,7 @@ import { URI, UriComponents } from 'vs/base/common/uri'; import * as modes from 'vs/editor/common/modes'; import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments'; import * as extHostTypeConverter from 'vs/workbench/api/node/extHostTypeConverters'; +import * as types from 'vs/workbench/api/node/extHostTypes'; import * as vscode from 'vscode'; import { ExtHostCommentsShape, IMainContext, MainContext, MainThreadCommentsShape } from './extHost.protocol'; import { CommandsConverter, ExtHostCommands } from './extHostCommands'; @@ -316,7 +317,7 @@ export class ExtHostCommentThread implements vscode.CommentThread { this._proxy.$updateCommentThreadCommands(this._commentControlHandle, this.handle, internals); } - private _collapseState?: vscode.CommentThreadCollapsibleState = vscode.CommentThreadCollapsibleState.Collapsed; + private _collapseState?: vscode.CommentThreadCollapsibleState; get collapsibleState(): vscode.CommentThreadCollapsibleState { return this._collapseState; @@ -324,8 +325,7 @@ export class ExtHostCommentThread implements vscode.CommentThread { set collapsibleState(newState: vscode.CommentThreadCollapsibleState) { this._collapseState = newState; - this._proxy.$updateCommentThreadCollapsibleState(this._commentControlHandle, this.handle, newState); - + this._proxy.$updateCommentThreadCollapsibleState(this._commentControlHandle, this.handle, convertToCollapsibleState(newState)); } constructor( @@ -625,4 +625,16 @@ function convertFromReaction(reaction: modes.CommentReaction): vscode.CommentRea count: reaction.count, hasReacted: reaction.hasReacted }; +} + +function convertToCollapsibleState(kind: vscode.CommentThreadCollapsibleState | undefined): modes.CommentThreadCollapsibleState { + if (kind !== undefined) { + switch (kind) { + case types.CommentThreadCollapsibleState.Expanded: + return modes.CommentThreadCollapsibleState.Expanded; + case types.CommentThreadCollapsibleState.Collapsed: + return modes.CommentThreadCollapsibleState.Collapsed; + } + } + return modes.CommentThreadCollapsibleState.Collapsed; } \ No newline at end of file