Skip to content

Commit 3202fa6

Browse files
authored
Handle bad directory watch on web (microsoft#223542)
Fix microsoft#221299 toResource throws here because we're tyring to watch directories outside of the workspace root. Should be fixed on TS side. Until them, adding a `catch`
1 parent ad09ae2 commit 3202fa6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

extensions/typescript-language-features/web/src/serverHost.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { FileWatcherManager } from './fileWatcherManager';
1111
import { Logger } from './logging';
1212
import { PathMapper, looksLikeNodeModules, mapUri } from './pathMapper';
1313
import { findArgument, hasArgument } from './util/args';
14+
import { URI } from 'vscode-uri';
1415

1516
type ServerHostWithImport = ts.server.ServerHost & { importPlugin(root: string, moduleName: string): Promise<ts.server.ModuleImportResult> };
1617

@@ -349,7 +350,13 @@ function createServerHost(
349350
return path;
350351
}
351352

352-
let uri = pathMapper.toResource(path);
353+
let uri: URI;
354+
try {
355+
uri = pathMapper.toResource(path);
356+
} catch {
357+
return path;
358+
}
359+
353360
if (isNm) {
354361
uri = mapUri(uri, 'vscode-node-modules');
355362
}

0 commit comments

Comments
 (0)