mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
@@ -83,10 +83,9 @@ class TscTaskProvider implements vscode.TaskProvider {
|
||||
if (editor) {
|
||||
if (path.basename(editor.document.fileName).match(/^tsconfig\.(.\.)?json$/)) {
|
||||
const path = editor.document.uri;
|
||||
const folder = vscode.workspace.getWorkspaceFolder(path);
|
||||
return [{
|
||||
path: path.fsPath,
|
||||
workspaceFolder: folder
|
||||
workspaceFolder: vscode.workspace.getWorkspaceFolder(path)
|
||||
}];
|
||||
}
|
||||
}
|
||||
@@ -96,23 +95,28 @@ class TscTaskProvider implements vscode.TaskProvider {
|
||||
return [];
|
||||
}
|
||||
|
||||
const res: Proto.ProjectInfoResponse = await this.lazyClient().execute(
|
||||
'projectInfo',
|
||||
{ file, needFileNameList: false } as protocol.ProjectInfoRequestArgs,
|
||||
token);
|
||||
try {
|
||||
const res: Proto.ProjectInfoResponse = await this.lazyClient().execute(
|
||||
'projectInfo',
|
||||
{ file, needFileNameList: false } as protocol.ProjectInfoRequestArgs,
|
||||
token);
|
||||
|
||||
if (!res || !res.body) {
|
||||
return [];
|
||||
if (!res || !res.body) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const { configFileName } = res.body;
|
||||
if (configFileName && !isImplicitProjectConfigFile(configFileName)) {
|
||||
const path = vscode.Uri.file(configFileName);
|
||||
const folder = vscode.workspace.getWorkspaceFolder(path);
|
||||
return [{
|
||||
path: configFileName,
|
||||
workspaceFolder: folder
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
const { configFileName } = res.body;
|
||||
if (configFileName && !isImplicitProjectConfigFile(configFileName)) {
|
||||
const path = vscode.Uri.file(configFileName);
|
||||
const folder = vscode.workspace.getWorkspaceFolder(path);
|
||||
return [{
|
||||
path: configFileName,
|
||||
workspaceFolder: folder
|
||||
}];
|
||||
catch (e) {
|
||||
// noop
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ export interface TSConfig {
|
||||
workspaceFolder?: vscode.WorkspaceFolder;
|
||||
}
|
||||
|
||||
const tsconfigGlob = '**/tsconfig*.json';
|
||||
|
||||
export default class TsConfigProvider extends vscode.Disposable {
|
||||
private readonly tsconfigs = new Map<string, TSConfig>();
|
||||
|
||||
@@ -37,9 +39,9 @@ export default class TsConfigProvider extends vscode.Disposable {
|
||||
}
|
||||
this.activated = true;
|
||||
|
||||
this.reloadWorkspaceConfigs();
|
||||
await this.reloadWorkspaceConfigs();
|
||||
|
||||
const configFileWatcher = vscode.workspace.createFileSystemWatcher('**/tsconfig*.json');
|
||||
const configFileWatcher = vscode.workspace.createFileSystemWatcher(tsconfigGlob);
|
||||
this.disposables.push(configFileWatcher);
|
||||
configFileWatcher.onDidCreate(this.handleProjectCreate, this, this.disposables);
|
||||
configFileWatcher.onDidDelete(this.handleProjectDelete, this, this.disposables);
|
||||
@@ -53,7 +55,7 @@ export default class TsConfigProvider extends vscode.Disposable {
|
||||
|
||||
private async reloadWorkspaceConfigs(): Promise<this> {
|
||||
this.tsconfigs.clear();
|
||||
for (const config of await vscode.workspace.findFiles('**/tsconfig*.json', '**/node_modules/**')) {
|
||||
for (const config of await vscode.workspace.findFiles(tsconfigGlob, '**/node_modules/**')) {
|
||||
this.handleProjectCreate(config);
|
||||
}
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user