Merge from vscode 4d91d96e5e121b38d33508cdef17868bab255eae

This commit is contained in:
ADS Merger
2020-06-18 04:32:54 +00:00
committed by AzureDataStudio
parent a971aee5bd
commit 5e7071e466
1002 changed files with 24201 additions and 13193 deletions

View File

@@ -81,6 +81,7 @@ import { find } from 'vs/base/common/arrays';
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
import { IViewsService, IViewDescriptorService } from 'vs/workbench/common/views';
import { isWorkspaceFolder, TaskQuickPickEntry, QUICKOPEN_DETAIL_CONFIG, TaskQuickPick, QUICKOPEN_SKIP_CONFIG } from 'vs/workbench/contrib/tasks/browser/taskQuickPick';
import { ILogService } from 'vs/platform/log/common/log';
const QUICKOPEN_HISTORY_LIMIT_CONFIG = 'task.quickOpen.history';
const PROBLEM_MATCHER_NEVER_CONFIG = 'task.problemMatchers.neverPrompt';
@@ -255,7 +256,8 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
@IPathService private readonly pathService: IPathService,
@ITextModelService private readonly textModelResolverService: ITextModelService,
@IPreferencesService private readonly preferencesService: IPreferencesService,
@IViewDescriptorService private readonly viewDescriptorService: IViewDescriptorService
@IViewDescriptorService private readonly viewDescriptorService: IViewDescriptorService,
@ILogService private readonly logService: ILogService
) {
super();
@@ -554,6 +556,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
}
public async tryResolveTask(configuringTask: ConfiguringTask): Promise<Task | undefined> {
await Promise.all([this.extensionService.activateByEvent('onCommand:workbench.action.tasks.runTask'), this.extensionService.whenInstalledExtensionsRegistered()]);
let matchingProvider: ITaskProvider | undefined;
for (const [handle, provider] of this._providers) {
if (configuringTask.type === this._providerTypes.get(handle)) {
@@ -1051,7 +1054,29 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
return false;
}
private openEditorAtTask(resource: URI | undefined, task: TaskConfig.CustomTask | TaskConfig.ConfiguringTask | string | undefined): Promise<boolean> {
private async formatTaskForJson(resource: URI, task: TaskConfig.CustomTask | TaskConfig.ConfiguringTask): Promise<string> {
let reference: IReference<IResolvedTextEditorModel> | undefined;
let stringValue: string = '';
try {
reference = await this.textModelResolverService.createModelReference(resource);
const model = reference.object.textEditorModel;
const { tabSize, insertSpaces } = model.getOptions();
const eol = model.getEOL();
const edits = format(JSON.stringify(task), undefined, { eol, tabSize, insertSpaces });
let stringified = applyEdits(JSON.stringify(task), edits);
const regex = new RegExp(eol + '\\t', 'g');
stringified = stringified.replace(regex, eol + '\t\t\t');
const twoTabs = '\t\t';
stringValue = twoTabs + stringified.slice(0, stringified.length - 1) + twoTabs + stringified.slice(stringified.length - 1);
} finally {
if (reference) {
reference.dispose();
}
}
return stringValue;
}
private openEditorAtTask(resource: URI | undefined, task: TaskConfig.CustomTask | TaskConfig.ConfiguringTask | string | undefined, configIndex: number = -1): Promise<boolean> {
if (resource === undefined) {
return Promise.resolve(false);
}
@@ -1062,26 +1087,18 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
}
if (task) {
const contentValue = content.toString();
let stringValue: string;
if (typeof task === 'string') {
stringValue = task;
} else {
let reference: IReference<IResolvedTextEditorModel> | undefined;
try {
reference = await this.textModelResolverService.createModelReference(resource);
const model = reference.object.textEditorModel;
const { tabSize, insertSpaces } = model.getOptions();
const eol = model.getEOL();
const edits = format(JSON.stringify(task), undefined, { eol, tabSize, insertSpaces });
let stringified = applyEdits(JSON.stringify(task), edits);
const regex = new RegExp(eol + '\\t', 'g');
stringified = stringified.replace(regex, eol + '\t\t\t');
const twoTabs = '\t\t';
stringValue = twoTabs + stringified.slice(0, stringified.length - 1) + twoTabs + stringified.slice(stringified.length - 1);
} finally {
if (reference) {
reference.dispose();
}
let stringValue: string | undefined;
if (configIndex !== -1) {
const json: TaskConfig.ExternalTaskRunnerConfiguration = JSON.parse(contentValue);
if (json.tasks && (json.tasks.length > configIndex)) {
stringValue = await this.formatTaskForJson(resource, json.tasks[configIndex]);
}
}
if (!stringValue) {
if (typeof task === 'string') {
stringValue = task;
} else {
stringValue = await this.formatTaskForJson(resource, task);
}
}
@@ -1280,14 +1297,14 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
}
}
public openConfig(task: CustomTask | ConfiguringTask | undefined): Promise<boolean> {
public async openConfig(task: CustomTask | ConfiguringTask | undefined): Promise<boolean> {
let resource: URI | undefined;
if (task) {
resource = this.getResourceForTask(task);
} else {
resource = (this._workspaceFolders && (this._workspaceFolders.length > 0)) ? this._workspaceFolders[0].toResource('.vscode/tasks.json') : undefined;
}
return this.openEditorAtTask(resource, task ? task._label : undefined);
return this.openEditorAtTask(resource, task ? task._label : undefined, task ? task._source.config.index : -1);
}
private createRunnableTask(tasks: TaskMap, group: TaskGroup): { task: Task; resolver: ITaskResolver } | undefined {
@@ -1532,7 +1549,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
this.modelService, this.configurationResolverService, this.telemetryService,
this.contextService, this.environmentService,
AbstractTaskService.OutputChannelId, this.fileService, this.terminalInstanceService,
this.pathService, this.viewDescriptorService,
this.pathService, this.viewDescriptorService, this.logService,
(workspaceFolder: IWorkspaceFolder) => {
if (!workspaceFolder) {
return undefined;