-
Notifications
You must be signed in to change notification settings - Fork 30.7k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"description": "Extension to add Gulp capabilities to VSCode.", | ||
"displayName": "Gulp support for VSCode", | ||
"config.gulp.autoDetect": "Controls whether auto detection of Gulp tasks is on or off. Default is on.", | ||
"config.gulp.autoDetect": "Controls enablement of Gulp task detection. Gulp task detection can cause files in any open workspace to be executed.", | ||
"gulp.taskDefinition.type.description": "The Gulp task to customize.", | ||
"gulp.taskDefinition.file.description": "The Gulp file that provides the task. Can be omitted." | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,11 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur | |
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput'; | ||
import { Disposable } from 'vs/base/common/lifecycle'; | ||
import { Event } from 'vs/base/common/event'; | ||
import { INotificationService } from 'vs/platform/notification/common/notification'; | ||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; | ||
import { Codicon } from 'vs/base/common/codicons'; | ||
import { ThemeIcon } from 'vs/platform/theme/common/themeService'; | ||
import { registerIcon } from 'vs/platform/theme/common/iconRegistry'; | ||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; | ||
|
||
export const QUICKOPEN_DETAIL_CONFIG = 'task.quickOpen.detail'; | ||
export const QUICKOPEN_SKIP_CONFIG = 'task.quickOpen.skip'; | ||
|
@@ -29,8 +30,10 @@ export function isWorkspaceFolder(folder: IWorkspace | IWorkspaceFolder): folder | |
export interface TaskQuickPickEntry extends IQuickPickItem { | ||
task: Task | undefined | null; | ||
} | ||
|
||
export interface TaskTwoLevelQuickPickEntry extends IQuickPickItem { | ||
task: Task | ConfiguringTask | string | undefined | null; | ||
settingType?: string; | ||
} | ||
|
||
const SHOW_ALL: string = nls.localize('taskQuickPick.showAll', "Show All Tasks..."); | ||
|
@@ -45,7 +48,8 @@ export class TaskQuickPick extends Disposable { | |
private taskService: ITaskService, | ||
private configurationService: IConfigurationService, | ||
private quickInputService: IQuickInputService, | ||
private notificationService: INotificationService) { | ||
private notificationService: INotificationService, | ||
private dialogService: IDialogService) { | ||
super(); | ||
this.sorter = this.taskService.createSorter(); | ||
} | ||
|
@@ -173,6 +177,21 @@ export class TaskQuickPick extends Disposable { | |
return { entries: this.topLevelEntries, isSingleConfigured: configuredTasks.length === 1 ? configuredTasks[0] : undefined }; | ||
} | ||
|
||
public async handleSettingOption(selectedType: string) { | ||
const noButton = nls.localize('TaskQuickPick.changeSettingNo', "No"); | ||
const yesButton = nls.localize('TaskQuickPick.changeSettingYes', "Yes"); | ||
const changeSettingResult = await this.dialogService.show(Severity.Warning, | ||
nls.localize('TaskQuickPick.changeSettingDetails', | ||
"Task detection for {0} tasks causes files in any workspace you open to be run as code. Enabling {0} task detection is a user setting and will apply to any workspace you open. Do you want to enable {0} task detection for all workspaces?", selectedType), | ||
[noButton, yesButton]); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
alexr00
Member
|
||
if (changeSettingResult.choice === 1) { | ||
await this.configurationService.updateValue(`${selectedType}.autoDetect`, 'on'); | ||
await new Promise<void>(resolve => setTimeout(() => resolve(), 100)); | ||
return this.show(nls.localize('TaskService.pickRunTask', 'Select the task to run'), undefined, selectedType); | ||
} | ||
return undefined; | ||
} | ||
|
||
public async show(placeHolder: string, defaultEntry?: TaskQuickPickEntry, startAtType?: string): Promise<Task | undefined | null> { | ||
const picker: IQuickPick<TaskTwoLevelQuickPickEntry> = this.quickInputService.createQuickPick(); | ||
picker.placeholder = placeHolder; | ||
|
@@ -218,9 +237,12 @@ export class TaskQuickPick extends Disposable { | |
if (Types.isString(firstLevelTask)) { | ||
// Proceed to second level of quick pick | ||
const selectedEntry = await this.doPickerSecondLevel(picker, firstLevelTask); | ||
if (selectedEntry && selectedEntry.task === null) { | ||
if (selectedEntry && !selectedEntry.settingType && selectedEntry.task === null) { | ||
// The user has chosen to go back to the first level | ||
firstLevelTask = await this.doPickerFirstLevel(picker, (await this.getTopLevelEntries(defaultEntry)).entries); | ||
} else if (selectedEntry && Types.isString(selectedEntry.settingType)) { | ||
picker.dispose(); | ||
return this.handleSettingOption(selectedEntry.settingType); | ||
} else { | ||
picker.dispose(); | ||
return (selectedEntry?.task && !Types.isString(selectedEntry?.task)) ? this.toTask(selectedEntry?.task) : undefined; | ||
|
@@ -249,7 +271,9 @@ export class TaskQuickPick extends Disposable { | |
private async doPickerSecondLevel(picker: IQuickPick<TaskTwoLevelQuickPickEntry>, type: string) { | ||
picker.busy = true; | ||
if (type === SHOW_ALL) { | ||
picker.items = (await this.taskService.tasks()).sort((a, b) => this.sorter.compare(a, b)).map(task => this.createTaskEntry(task)); | ||
const items = (await this.taskService.tasks()).sort((a, b) => this.sorter.compare(a, b)).map(task => this.createTaskEntry(task)); | ||
items.push(...TaskQuickPick.allSettingEntries(this.configurationService)); | ||
picker.items = items; | ||
} else { | ||
picker.value = ''; | ||
picker.items = await this.getEntriesForProvider(type); | ||
|
@@ -264,6 +288,36 @@ export class TaskQuickPick extends Disposable { | |
return secondLevelPickerResult; | ||
} | ||
|
||
public static allSettingEntries(configurationService: IConfigurationService): (TaskTwoLevelQuickPickEntry & { settingType: string })[] { | ||
const entries: (TaskTwoLevelQuickPickEntry & { settingType: string })[] = []; | ||
const gruntEntry = TaskQuickPick.getSettingEntry(configurationService, 'grunt'); | ||
if (gruntEntry) { | ||
entries.push(gruntEntry); | ||
} | ||
const gulpEntry = TaskQuickPick.getSettingEntry(configurationService, 'gulp'); | ||
if (gulpEntry) { | ||
entries.push(gulpEntry); | ||
} | ||
const jakeEntry = TaskQuickPick.getSettingEntry(configurationService, 'jake'); | ||
if (jakeEntry) { | ||
entries.push(jakeEntry); | ||
} | ||
return entries; | ||
} | ||
|
||
public static getSettingEntry(configurationService: IConfigurationService, type: string): (TaskTwoLevelQuickPickEntry & { settingType: string }) | undefined { | ||
if (configurationService.getValue(`${type}.autoDetect`) === 'off') { | ||
return { | ||
label: nls.localize('TaskQuickPick.changeSettingsOptions', "$(gear) {0} task detection is turned off. Enable {1} task detection...", | ||
type[0].toUpperCase() + type.slice(1), type), | ||
task: null, | ||
settingType: type, | ||
alwaysShow: true | ||
}; | ||
} | ||
return undefined; | ||
} | ||
|
||
private async getEntriesForProvider(type: string): Promise<QuickPickInput<TaskTwoLevelQuickPickEntry>[]> { | ||
const tasks = (await this.taskService.tasks({ type })).sort((a, b) => this.sorter.compare(a, b)); | ||
let taskQuickPickEntries: QuickPickInput<TaskTwoLevelQuickPickEntry>[]; | ||
|
@@ -283,6 +337,11 @@ export class TaskQuickPick extends Disposable { | |
alwaysShow: true | ||
}]; | ||
} | ||
|
||
const settingEntry = TaskQuickPick.getSettingEntry(this.configurationService, type); | ||
if (settingEntry) { | ||
taskQuickPickEntries.push(settingEntry); | ||
} | ||
return taskQuickPickEntries; | ||
} | ||
|
||
|
@@ -299,8 +358,10 @@ export class TaskQuickPick extends Disposable { | |
return resolvedTask; | ||
} | ||
|
||
static async show(taskService: ITaskService, configurationService: IConfigurationService, quickInputService: IQuickInputService, notificationService: INotificationService, placeHolder: string, defaultEntry?: TaskQuickPickEntry) { | ||
const taskQuickPick = new TaskQuickPick(taskService, configurationService, quickInputService, notificationService); | ||
static async show(taskService: ITaskService, configurationService: IConfigurationService, | ||
quickInputService: IQuickInputService, notificationService: INotificationService, | ||
dialogService: IDialogService, placeHolder: string, defaultEntry?: TaskQuickPickEntry) { | ||
const taskQuickPick = new TaskQuickPick(taskService, configurationService, quickInputService, notificationService, dialogService); | ||
return taskQuickPick.show(placeHolder, defaultEntry); | ||
} | ||
} |
@meganrogge is this intentionally putting the
noButton
first?