@@ -15,7 +15,11 @@ import { Logger } from './logging';
15
15
import { IFeature } from './feature' ;
16
16
import { Message } from 'vscode-jsonrpc' ;
17
17
import { 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' ;
19
23
20
24
export enum SessionStatus {
21
25
NotStarted ,
@@ -58,7 +62,7 @@ type SessionConfiguration =
58
62
PathSessionConfiguration |
59
63
BuiltInSessionConfiguration ;
60
64
61
- export class SessionManager {
65
+ export class SessionManager implements Middleware {
62
66
63
67
private ShowSessionMenuCommandName = "PowerShell.ShowSessionMenu" ;
64
68
@@ -471,7 +475,9 @@ export class SessionManager {
471
475
// We have our own restart experience
472
476
return CloseAction . DoNotRestart
473
477
}
474
- }
478
+ } ,
479
+ revealOutputChannelOn : RevealOutputChannelOn . Never ,
480
+ middleware : this
475
481
}
476
482
477
483
this . languageServerClient =
@@ -793,6 +799,53 @@ export class SessionManager {
793
799
. showQuickPick < SessionMenuItem > ( menuItems )
794
800
. then ( ( selectedItem ) => { selectedItem . callback ( ) ; } ) ;
795
801
}
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
+ }
796
849
}
797
850
798
851
class SessionMenuItem implements vscode . QuickPickItem {
0 commit comments