Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit 74f5c69

Browse files
committed
Fix relative workspace folder paths under Windows
1 parent fe0fc55 commit 74f5c69

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/extension.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
workspace,
1414
WorkspaceFolder,
1515
WorkspaceFoldersChangeEvent,
16+
RelativePattern,
1617
} from 'vscode';
1718
import {
1819
LanguageClient,
@@ -203,18 +204,18 @@ class ClientWorkspace {
203204
return this.makeRlsProcess();
204205
};
205206

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;
213215

214216
const collectionName = `rust (${this.folder.uri.toString()})`;
215217
const clientOptions: LanguageClientOptions = {
216218
// Register the server for Rust files
217-
218219
documentSelector: [
219220
{ language: 'rust', scheme: 'file', pattern },
220221
{ language: 'rust', scheme: 'untitled', pattern },

0 commit comments

Comments
 (0)