@@ -15,7 +15,11 @@ import { Logger } from './logging';
1515import { IFeature } from './feature' ;
1616import { Message } from 'vscode-jsonrpc' ;
1717import { StringDecoder } from 'string_decoder' ;
18- import { LanguageClient , LanguageClientOptions , Executable , RequestType , RequestType0 , NotificationType , StreamInfo , ErrorAction , CloseAction } from 'vscode-languageclient' ;
18+ import {
19+ LanguageClient , LanguageClientOptions , Executable ,
20+ RequestType , RequestType0 , NotificationType ,
21+ StreamInfo , ErrorAction , CloseAction , RevealOutputChannelOn ,
22+ Middleware , ResolveCodeLensSignature } from 'vscode-languageclient' ;
1923
2024export enum SessionStatus {
2125 NotStarted ,
@@ -58,7 +62,7 @@ type SessionConfiguration =
5862 PathSessionConfiguration |
5963 BuiltInSessionConfiguration ;
6064
61- export class SessionManager {
65+ export class SessionManager implements Middleware {
6266
6367 private ShowSessionMenuCommandName = "PowerShell.ShowSessionMenu" ;
6468
@@ -471,7 +475,9 @@ export class SessionManager {
471475 // We have our own restart experience
472476 return CloseAction . DoNotRestart
473477 }
474- }
478+ } ,
479+ revealOutputChannelOn : RevealOutputChannelOn . Never ,
480+ middleware : this
475481 }
476482
477483 this . languageServerClient =
@@ -793,6 +799,53 @@ export class SessionManager {
793799 . showQuickPick < SessionMenuItem > ( menuItems )
794800 . then ( ( selectedItem ) => { selectedItem . callback ( ) ; } ) ;
795801 }
802+
803+ // ----- LanguageClient middleware methods -----
804+
805+ resolveCodeLens (
806+ codeLens : vscode . CodeLens ,
807+ token : vscode . CancellationToken ,
808+ next : ResolveCodeLensSignature ) : vscode . ProviderResult < vscode . CodeLens > {
809+ var resolvedCodeLens = next ( codeLens , token ) ;
810+
811+ let resolveFunc =
812+ ( codeLens : vscode . CodeLens ) : vscode . CodeLens => {
813+ if ( codeLens . command . command === "editor.action.showReferences" ) {
814+ var oldArgs = codeLens . command . arguments ;
815+
816+ // Our JSON objects don't get handled correctly by
817+ // VS Code's built in editor.action.showReferences
818+ // command so we need to convert them into the
819+ // appropriate types to send them as command
820+ // arguments.
821+
822+ codeLens . command . arguments = [
823+ vscode . Uri . parse ( oldArgs [ 0 ] ) ,
824+ new vscode . Position ( oldArgs [ 1 ] . line , oldArgs [ 1 ] . character ) ,
825+ oldArgs [ 2 ] . map ( position => {
826+ return new vscode . Location (
827+ vscode . Uri . parse ( position . uri ) ,
828+ new vscode . Range (
829+ position . range . start . line ,
830+ position . range . start . character ,
831+ position . range . end . line ,
832+ position . range . end . character ) ) ;
833+ } )
834+ ]
835+ }
836+
837+ return codeLens ;
838+ }
839+
840+ if ( ( < Thenable < vscode . CodeLens > > resolvedCodeLens ) . then ) {
841+ return ( < Thenable < vscode . CodeLens > > resolvedCodeLens ) . then ( resolveFunc ) ;
842+ }
843+ else if ( < vscode . CodeLens > resolvedCodeLens ) {
844+ return resolveFunc ( < vscode . CodeLens > resolvedCodeLens ) ;
845+ }
846+
847+ return resolvedCodeLens ;
848+ }
796849}
797850
798851class SessionMenuItem implements vscode . QuickPickItem {
0 commit comments