mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-30 05:21:08 +01:00
Skip watching lib files on web (#173601)
These files can never change on web so there is no point in creating a watcher for them
This commit is contained in:
@@ -97,6 +97,10 @@ function createServerHost(extensionUri: URI, logger: ts.server.Logger, apiClient
|
||||
|
||||
return {
|
||||
watchFile(path: string, callback: ts.FileWatcherCallback, pollingInterval?: number, options?: ts.WatchOptions): ts.FileWatcher {
|
||||
if (looksLikeLibDtsPath(path)) { // We don't support watching lib files on web since they are readonly
|
||||
return { close() { } };
|
||||
}
|
||||
|
||||
logVerbose('fs.watchFile', { path });
|
||||
|
||||
watchFiles.set(path, { path, callback, pollingInterval, options });
|
||||
@@ -390,7 +394,7 @@ function createServerHost(extensionUri: URI, logger: ts.server.Logger, apiClient
|
||||
* Copied from toResource in typescriptServiceClient.ts
|
||||
*/
|
||||
function toResource(filepath: string): URI {
|
||||
if (filepath.startsWith('/lib.') && filepath.endsWith('.d.ts')) {
|
||||
if (looksLikeLibDtsPath(filepath)) {
|
||||
return URI.from({
|
||||
scheme: extensionUri.scheme,
|
||||
authority: extensionUri.authority,
|
||||
@@ -427,6 +431,10 @@ function createServerHost(extensionUri: URI, logger: ts.server.Logger, apiClient
|
||||
}
|
||||
}
|
||||
|
||||
function looksLikeLibDtsPath(filepath: string) {
|
||||
return filepath.startsWith('/lib.') && filepath.endsWith('.d.ts');
|
||||
}
|
||||
|
||||
function filePathToResourceUri(filepath: string): URI | undefined {
|
||||
const parts = filepath.match(/^\/([^\/]+)\/([^\/]*)(?:\/(.+))?$/);
|
||||
if (!parts) {
|
||||
|
||||
Reference in New Issue
Block a user