@@ -13,6 +13,7 @@ import {
13
13
workspace ,
14
14
WorkspaceFolder ,
15
15
WorkspaceFoldersChangeEvent ,
16
+ RelativePattern ,
16
17
} from 'vscode' ;
17
18
import {
18
19
LanguageClient ,
@@ -203,18 +204,18 @@ class ClientWorkspace {
203
204
return this . makeRlsProcess ( ) ;
204
205
} ;
205
206
206
- // Something else is put front of files when pattern matching that prevents the windows version from picking up the files
207
- // This should be safe as the uri is a absolute path that includes the drive + colon
208
- // i.e. a pattern would become "**/c:/some/path**" and since colon is reserved only the root can ever contain it.
209
- const isWin = process . platform === 'win32' ;
210
- const windowsHack = isWin ? '**' : '' ;
211
-
212
- const pattern = `${ windowsHack } ${ this . folder . uri . path } /**` ;
207
+ // FIXME: vscode-languageserver-node internally uses `pattern` here as
208
+ // `vscode.GlobPattern` but only types it out as `string` type. We use
209
+ // `RelativePattern` to reliably match files relative to a workspace folder
210
+ // in a way that's supported in a cross-platform fashion.
211
+ const pattern = ( new RelativePattern (
212
+ this . folder ,
213
+ '**' ,
214
+ ) as unknown ) as string ;
213
215
214
216
const collectionName = `rust (${ this . folder . uri . toString ( ) } )` ;
215
217
const clientOptions : LanguageClientOptions = {
216
218
// Register the server for Rust files
217
-
218
219
documentSelector : [
219
220
{ language : 'rust' , scheme : 'file' , pattern } ,
220
221
{ language : 'rust' , scheme : 'untitled' , pattern } ,
0 commit comments