Skip to content

Commit

Permalink
Handle bad directory watch on web
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
mjbvz committed Jul 24, 2024
1 parent 06643dd commit b1f6d2f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { FileWatcherManager } from './fileWatcherManager';
import { Logger } from './logging';
import { PathMapper, looksLikeNodeModules, mapUri } from './pathMapper';
import { findArgument, hasArgument } from './util/args';
import { URI } from 'vscode-uri';

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

Expand Down Expand Up @@ -349,7 +350,13 @@ function createServerHost(
return path;
}

let uri = pathMapper.toResource(path);
let uri: URI;
try {
uri = pathMapper.toResource(path);
} catch {
return path;
}

if (isNm) {
uri = mapUri(uri, 'vscode-node-modules');
}
Expand Down

0 comments on commit b1f6d2f

Please sign in to comment.