@@ -16,6 +16,7 @@ import {
16
16
17
17
import { findConfigFile as findGQLConfigFile } from '@playlyfe/gql-language-server' ;
18
18
import ClientStatusBarItem from './ClientStatusBarItem' ;
19
+ import { isExtensionRunningLocally } from './utils' ;
19
20
20
21
const EXT_NAME = 'graphqlForVSCode' ;
21
22
const GQL_LANGUAGE_SERVER_CLI_PATH = require . resolve (
@@ -31,9 +32,11 @@ interface IClient {
31
32
const clients : Map < string , IClient | null > = new Map ( ) ;
32
33
33
34
export function activate ( context : ExtensionContext ) {
34
- createClientForWorkspaces ( ) ;
35
+ createClientForWorkspaces ( context ) ;
35
36
// update clients when workspaceFolderChanges
36
- Workspace . onDidChangeWorkspaceFolders ( createClientForWorkspaces ) ;
37
+ Workspace . onDidChangeWorkspaceFolders ( ( ) => {
38
+ createClientForWorkspaces ( context ) ;
39
+ } ) ;
37
40
}
38
41
39
42
export function deactivate ( ) : Thenable < void > {
@@ -46,14 +49,14 @@ export function deactivate(): Thenable<void> {
46
49
return Promise . all ( promises ) . then ( ( ) => undefined ) ;
47
50
}
48
51
49
- function createClientForWorkspaces ( ) {
52
+ function createClientForWorkspaces ( context : ExtensionContext ) {
50
53
const workspaceFolders = Workspace . workspaceFolders || [ ] ;
51
54
const workspaceFoldersIndex : { [ key : string ] : boolean } = { } ;
52
55
53
56
workspaceFolders . forEach ( folder => {
54
57
const key = folder . uri . toString ( ) ;
55
58
if ( ! clients . has ( key ) ) {
56
- const client = createClientForWorkspace ( folder ) ;
59
+ const client = createClientForWorkspace ( folder , context ) ;
57
60
// console.log('adding client', key, client);
58
61
clients . set ( key , client ) ;
59
62
}
@@ -73,7 +76,10 @@ function createClientForWorkspaces() {
73
76
} ) ;
74
77
}
75
78
76
- function createClientForWorkspace ( folder : WorkspaceFolder ) : null | IClient {
79
+ function createClientForWorkspace (
80
+ folder : WorkspaceFolder ,
81
+ context : ExtensionContext ,
82
+ ) : null | IClient {
77
83
// per workspacefolder settings
78
84
const config = Workspace . getConfiguration ( EXT_NAME , folder . uri ) ;
79
85
const outputChannel = window . createOutputChannel ( `GraphQL - ${ folder . name } ` ) ;
@@ -121,6 +127,12 @@ function createClientForWorkspace(folder: WorkspaceFolder): null | IClient {
121
127
} ,
122
128
} ;
123
129
130
+ // TEMP_FIX: relativePattern is not working when extension is
131
+ // running using vscode-remote with `local os = windows`
132
+ // NOTE: relativePattern is used only for optimization so it will
133
+ // not change the extension behaviour
134
+ const canUseRelativePattern = isExtensionRunningLocally ( context ) ;
135
+
124
136
// Options to control the language client
125
137
const clientOptions : LanguageClientOptions = {
126
138
diagnosticCollectionName : 'graphql' ,
@@ -136,7 +148,7 @@ function createClientForWorkspace(folder: WorkspaceFolder): null | IClient {
136
148
outputChannel,
137
149
workspaceFolder : folder ,
138
150
initializationOptions : {
139
- relativePattern : true ,
151
+ relativePattern : canUseRelativePattern ,
140
152
} ,
141
153
} ;
142
154
@@ -148,7 +160,7 @@ function createClientForWorkspace(folder: WorkspaceFolder): null | IClient {
148
160
clientOptions ,
149
161
) ;
150
162
151
- const statusBarItem = new ClientStatusBarItem ( client ) ;
163
+ const statusBarItem = new ClientStatusBarItem ( client , canUseRelativePattern ) ;
152
164
153
165
const subscriptions = [
154
166
client . start ( ) ,
0 commit comments