@@ -16,6 +16,7 @@ import {
1616
1717import { findConfigFile as findGQLConfigFile } from '@playlyfe/gql-language-server' ;
1818import ClientStatusBarItem from './ClientStatusBarItem' ;
19+ import { isExtensionRunningLocally } from './utils' ;
1920
2021const EXT_NAME = 'graphqlForVSCode' ;
2122const GQL_LANGUAGE_SERVER_CLI_PATH = require . resolve (
@@ -31,9 +32,11 @@ interface IClient {
3132const clients : Map < string , IClient | null > = new Map ( ) ;
3233
3334export function activate ( context : ExtensionContext ) {
34- createClientForWorkspaces ( ) ;
35+ createClientForWorkspaces ( context ) ;
3536 // update clients when workspaceFolderChanges
36- Workspace . onDidChangeWorkspaceFolders ( createClientForWorkspaces ) ;
37+ Workspace . onDidChangeWorkspaceFolders ( ( ) => {
38+ createClientForWorkspaces ( context ) ;
39+ } ) ;
3740}
3841
3942export function deactivate ( ) : Thenable < void > {
@@ -46,14 +49,14 @@ export function deactivate(): Thenable<void> {
4649 return Promise . all ( promises ) . then ( ( ) => undefined ) ;
4750}
4851
49- function createClientForWorkspaces ( ) {
52+ function createClientForWorkspaces ( context : ExtensionContext ) {
5053 const workspaceFolders = Workspace . workspaceFolders || [ ] ;
5154 const workspaceFoldersIndex : { [ key : string ] : boolean } = { } ;
5255
5356 workspaceFolders . forEach ( folder => {
5457 const key = folder . uri . toString ( ) ;
5558 if ( ! clients . has ( key ) ) {
56- const client = createClientForWorkspace ( folder ) ;
59+ const client = createClientForWorkspace ( folder , context ) ;
5760 // console.log('adding client', key, client);
5861 clients . set ( key , client ) ;
5962 }
@@ -73,7 +76,10 @@ function createClientForWorkspaces() {
7376 } ) ;
7477}
7578
76- function createClientForWorkspace ( folder : WorkspaceFolder ) : null | IClient {
79+ function createClientForWorkspace (
80+ folder : WorkspaceFolder ,
81+ context : ExtensionContext ,
82+ ) : null | IClient {
7783 // per workspacefolder settings
7884 const config = Workspace . getConfiguration ( EXT_NAME , folder . uri ) ;
7985 const outputChannel = window . createOutputChannel ( `GraphQL - ${ folder . name } ` ) ;
@@ -121,6 +127,12 @@ function createClientForWorkspace(folder: WorkspaceFolder): null | IClient {
121127 } ,
122128 } ;
123129
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+
124136 // Options to control the language client
125137 const clientOptions : LanguageClientOptions = {
126138 diagnosticCollectionName : 'graphql' ,
@@ -136,7 +148,7 @@ function createClientForWorkspace(folder: WorkspaceFolder): null | IClient {
136148 outputChannel,
137149 workspaceFolder : folder ,
138150 initializationOptions : {
139- relativePattern : true ,
151+ relativePattern : canUseRelativePattern ,
140152 } ,
141153 } ;
142154
@@ -148,7 +160,7 @@ function createClientForWorkspace(folder: WorkspaceFolder): null | IClient {
148160 clientOptions ,
149161 ) ;
150162
151- const statusBarItem = new ClientStatusBarItem ( client ) ;
163+ const statusBarItem = new ClientStatusBarItem ( client , canUseRelativePattern ) ;
152164
153165 const subscriptions = [
154166 client . start ( ) ,
0 commit comments