Fix some errors for project wide JS/TS IntelliSense (#183482)

- Don't compute `semanticSupportedSchemes` early, as this may be incorrect if the script is loaded before there are workspace folders

- Handle exceptions when watching files by logging them but not crashing the server
This commit is contained in:
Matt Bierner
2023-05-25 18:43:46 -07:00
committed by GitHub
parent 110b68473b
commit ea7d830fb4
4 changed files with 34 additions and 14 deletions

View File

@@ -19,13 +19,18 @@ export const memFs = 'memfs';
export const vscodeVfs = 'vscode-vfs';
export const officeScript = 'office-script';
export const semanticSupportedSchemes = isWeb() && vscode.workspace.workspaceFolders ?
vscode.workspace.workspaceFolders.map(folder => folder.uri.scheme) : [
export function getSemanticSupportedSchemes() {
if (isWeb() && vscode.workspace.workspaceFolders) {
return vscode.workspace.workspaceFolders.map(folder => folder.uri.scheme);
}
return [
file,
untitled,
walkThroughSnippet,
vscodeNotebookCell,
];
}
/**
* File scheme for which JS/TS language feature should be disabled

View File

@@ -46,7 +46,7 @@ export default class LanguageProvider extends Disposable {
const syntax: vscode.DocumentFilter[] = [];
for (const language of this.description.languageIds) {
syntax.push({ language });
for (const scheme of fileSchemes.semanticSupportedSchemes) {
for (const scheme of fileSchemes.getSemanticSupportedSchemes()) {
semantic.push({ language, scheme });
}
}

View File

@@ -719,15 +719,13 @@ export default class TypeScriptServiceClient extends Disposable implements IType
}
switch (capability) {
case ClientCapability.Semantic:
{
return fileSchemes.semanticSupportedSchemes.includes(resource.scheme);
}
case ClientCapability.Semantic: {
return fileSchemes.getSemanticSupportedSchemes().includes(resource.scheme);
}
case ClientCapability.Syntax:
case ClientCapability.EnhancedSyntax:
{
return true;
}
case ClientCapability.EnhancedSyntax: {
return true;
}
}
}