From c3e53cc22dc6eacdece76d772b6e027207a5a4c9 Mon Sep 17 00:00:00 2001 From: dfinke Date: Mon, 23 May 2016 19:37:27 -0400 Subject: [PATCH 1/3] Wired up Show Information|Warning|Error Message --- src/features/ExtensionCommands.ts | 59 +++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/features/ExtensionCommands.ts b/src/features/ExtensionCommands.ts index 9e81d4bf38..7ee4c7bca4 100644 --- a/src/features/ExtensionCommands.ts +++ b/src/features/ExtensionCommands.ts @@ -122,6 +122,26 @@ export namespace OpenFileRequest { { get method() { return 'editor/openFile'; } }; } +export namespace ShowErrorMessageRequest { + export const type: RequestType = + { get method() { return 'editor/showErrorMessage'; } }; +} + +export namespace ShowWarningMessageRequest { + export const type: RequestType = + { get method() { return 'editor/showWarningMessage'; } }; +} + +export namespace ShowInformationMessageRequest { + export const type: RequestType = + { get method() { return 'editor/showInformationMessage'; } }; +} + +export namespace SetStatusBarMessageRequest { + export const type: RequestType = + { get method() { return 'editor/setStatusBarMessage'; } }; +} + export class ExtensionCommandsFeature implements IFeature { private command: vscode.Disposable; @@ -172,6 +192,22 @@ export class ExtensionCommandsFeature implements IFeature { this.languageClient.onRequest( OpenFileRequest.type, filePath => this.openFile(filePath)); + + this.languageClient.onRequest( + ShowInformationMessageRequest.type, + message => this.showInformationMessage(message)); + + this.languageClient.onRequest( + ShowErrorMessageRequest.type, + message => this.showErrorMessage(message)); + + this.languageClient.onRequest( + ShowWarningMessageRequest.type, + message => this.showWarningMessage(message)); + + this.languageClient.onRequest( + SetStatusBarMessageRequest.type, + message => this.setStatusBarMessage(message)); } } @@ -285,4 +321,27 @@ export class ExtensionCommandsFeature implements IFeature { return EditorOperationResponse.Completed; } + + private showInformationMessage(message: string): Thenable { + return vscode.window + .showInformationMessage(message) + .then(_ => EditorOperationResponse.Completed); + } + + private showErrorMessage(message: string): Thenable { + return vscode.window + .showErrorMessage(message) + .then(_ => EditorOperationResponse.Completed); + } + + private showWarningMessage(message: string): Thenable { + return vscode.window + .showWarningMessage(message) + .then(_ => EditorOperationResponse.Completed); + } + + private setStatusBarMessage(message: string): EditorOperationResponse { + vscode.window.setStatusBarMessage(message); + return EditorOperationResponse.Completed; + } } From f4813262805f8d66289e7e14c1588a3c7eeaa365 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 7 Dec 2016 10:39:16 -0800 Subject: [PATCH 2/3] Fix IndentAction references in main.ts --- src/main.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 0ba1071886..804ecf7e65 100644 --- a/src/main.ts +++ b/src/main.ts @@ -55,27 +55,27 @@ export function activate(context: vscode.ExtensionContext): void { // e.g. /** | */ beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/, afterText: /^\s*\*\/$/, - action: { indentAction: IndentAction.IndentOutdent, appendText: ' * ' } + action: { indentAction: vscode.IndentAction.IndentOutdent, appendText: ' * ' } }, { // e.g. /** ...| beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/, - action: { indentAction: IndentAction.None, appendText: ' * ' } + action: { indentAction: vscode.IndentAction.None, appendText: ' * ' } }, { // e.g. * ...| beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/, - action: { indentAction: IndentAction.None, appendText: '* ' } + action: { indentAction: vscode.IndentAction.None, appendText: '* ' } }, { // e.g. */| beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/, - action: { indentAction: IndentAction.None, removeText: 1 } + action: { indentAction: vscode.IndentAction.None, removeText: 1 } }, { // e.g. *-----*/| beforeText: /^(\t|(\ \ ))*\ \*[^/]*\*\/\s*$/, - action: { indentAction: IndentAction.None, removeText: 1 } + action: { indentAction: vscode.IndentAction.None, removeText: 1 } } ] }); From d0bebbb8b06b5d3a996e41ea8c199a3ba21cee7e Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 7 Dec 2016 10:58:34 -0800 Subject: [PATCH 3/3] Add an adjustable timeout to the SetStatusBarMessage handler --- src/features/ExtensionCommands.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/features/ExtensionCommands.ts b/src/features/ExtensionCommands.ts index 7ee4c7bca4..745d86f620 100644 --- a/src/features/ExtensionCommands.ts +++ b/src/features/ExtensionCommands.ts @@ -138,10 +138,15 @@ export namespace ShowInformationMessageRequest { } export namespace SetStatusBarMessageRequest { - export const type: RequestType = + export const type: RequestType = { get method() { return 'editor/setStatusBarMessage'; } }; } +export interface StatusBarMessageDetails { + message: string; + timeout?: number; +} + export class ExtensionCommandsFeature implements IFeature { private command: vscode.Disposable; @@ -207,7 +212,7 @@ export class ExtensionCommandsFeature implements IFeature { this.languageClient.onRequest( SetStatusBarMessageRequest.type, - message => this.setStatusBarMessage(message)); + messageDetails => this.setStatusBarMessage(messageDetails)); } } @@ -340,8 +345,15 @@ export class ExtensionCommandsFeature implements IFeature { .then(_ => EditorOperationResponse.Completed); } - private setStatusBarMessage(message: string): EditorOperationResponse { - vscode.window.setStatusBarMessage(message); + private setStatusBarMessage(messageDetails: StatusBarMessageDetails): EditorOperationResponse { + + if (messageDetails.timeout) { + vscode.window.setStatusBarMessage(messageDetails.message, messageDetails.timeout); + } + else { + vscode.window.setStatusBarMessage(messageDetails.message); + } + return EditorOperationResponse.Completed; } }