Skip to content

Commit

Permalink
Configure Exclude status bar item should open config directly
Browse files Browse the repository at this point in the history
Fixes #21215
  • Loading branch information
mjbvz committed Aug 2, 2017
1 parent a65e0d3 commit 1b39981
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions extensions/typescript/src/utils/projectStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface ProjectHintedMap {
const fileLimit = 500;

class ExcludeHintItem {
public configFileName?: string;
private _item: vscode.StatusBarItem;
private _client: ITypescriptServiceClient;
private _currentHint: Hint;
Expand Down Expand Up @@ -133,36 +134,44 @@ function createLargeProjectMonitorFromTypeScript(item: ExcludeHintItem, client:
item.show();
const configFileName = body.projectName;
if (configFileName) {
item.configFileName = configFileName;
vscode.window.showWarningMessage<LargeProjectMessageItem>(item.getCurrentHint().message,
{
title: localize('large.label', "Configure Excludes"),
index: 0
}).then(selected => {
if (!selected || selected.index !== 0) {
return;
}
if (!isImplicitProjectConfigFile(configFileName)) {
vscode.workspace.openTextDocument(configFileName)
.then(vscode.window.showTextDocument);
} else {
const root = client.getWorkspaceRootForResource(vscode.Uri.file(configFileName));
if (root) {
openOrCreateConfigFile(
configFileName.match(/tsconfig\.?.*\.json/) !== null,
root);
}
if (selected && selected.index === 0) {
onConfigureExcludesSelected(client, configFileName);
}
});
}
}
});
}

function onConfigureExcludesSelected(client: ITypescriptServiceClient, configFileName: string) {
if (!isImplicitProjectConfigFile(configFileName)) {
vscode.workspace.openTextDocument(configFileName)
.then(vscode.window.showTextDocument);
} else {
const root = client.getWorkspaceRootForResource(vscode.Uri.file(configFileName));
if (root) {
openOrCreateConfigFile(
configFileName.match(/tsconfig\.?.*\.json/) !== null,
root);
}
}
});
}

export function create(client: ITypescriptServiceClient, isOpen: (path: string) => Promise<boolean>, memento: vscode.Memento) {
const toDispose: vscode.Disposable[] = [];

let item = new ExcludeHintItem(client);
const item = new ExcludeHintItem(client);
toDispose.push(vscode.commands.registerCommand('js.projectStatus.command', () => {
if (item.configFileName) {
onConfigureExcludesSelected(client, item.configFileName);
}
let { message } = item.getCurrentHint();
return vscode.window.showInformationMessage(message);
}));
Expand Down

0 comments on commit 1b39981

Please sign in to comment.