diff --git a/package.json b/package.json index ec5912101..fc9cfff88 100644 --- a/package.json +++ b/package.json @@ -215,6 +215,15 @@ "light": "res/light/favorite.svg" } }, + { + "command": "taskExplorerSideBar.renameSpecial", + "title": "%command.renameSpecial%", + "when": "config.taskExplorer.enableSideBar", + "icon": { + "light": "res/light/continue.svg", + "dark": "res/dark/continue.svg" + } + }, { "command": "taskExplorerSideBar.clearSpecialFolder", "title": "CLR", @@ -349,6 +358,15 @@ "light": "res/light/favorite.svg" } }, + { + "command": "taskExplorer.renameSpecial", + "title": "%command.renameSpecial%", + "when": "config.taskExplorer.enableExplorerView", + "icon": { + "light": "res/light/continue.svg", + "dark": "res/dark/continue.svg" + } + }, { "command": "taskExplorer.clearSpecialFolder", "title": "CLR", @@ -507,6 +525,18 @@ "command": "taskExplorer.open", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunning" }, + { + "command": "taskExplorer.open", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptS" + }, + { + "command": "taskExplorer.open", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFileS" + }, + { + "command": "taskExplorer.open", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunningS" + }, { "command": "taskExplorer.run", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == script" @@ -515,10 +545,22 @@ "command": "taskExplorer.run", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFile" }, + { + "command": "taskExplorer.run", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptS" + }, + { + "command": "taskExplorer.run", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFileS" + }, { "command": "taskExplorer.runWithArgs", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFile" }, + { + "command": "taskExplorer.runWithArgs", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFileS" + }, { "command": "taskExplorer.runNoTerm", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == script" @@ -527,6 +569,14 @@ "command": "taskExplorer.runNoTerm", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFile" }, + { + "command": "taskExplorer.runNoTerm", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptS" + }, + { + "command": "taskExplorer.runNoTerm", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFileS" + }, { "command": "taskExplorer.addToExcludes", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == taskFileApp-publisher" @@ -663,6 +713,30 @@ "command": "taskExplorer.addRemoveFromFavorites", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunning" }, + { + "command": "taskExplorer.addRemoveFromFavorites", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptS" + }, + { + "command": "taskExplorer.addRemoveFromFavorites", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFileS" + }, + { + "command": "taskExplorer.addRemoveFromFavorites", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunningS" + }, + { + "command": "taskExplorer.renameSpecial", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptS" + }, + { + "command": "taskExplorer.renameSpecial", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFileS" + }, + { + "command": "taskExplorer.renameSpecial", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunningS" + }, { "command": "taskExplorer.clearSpecialFolder", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == favorites" @@ -681,11 +755,36 @@ "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showExecuteWithNoTerminalButton && view == taskExplorer && viewItem == scriptFile", "group": "inline" }, + { + "command": "taskExplorer.runNoTerm", + "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showExecuteWithNoTerminalButton && view == taskExplorer && viewItem == scriptS", + "group": "inline" + }, + { + "command": "taskExplorer.runNoTerm", + "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showExecuteWithNoTerminalButton && view == taskExplorer && viewItem == scriptFileS", + "group": "inline" + }, + { + "command": "taskExplorer.runWithArgs", + "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showExecuteWithArgumentsButton && view == taskExplorer && viewItem == scriptFile", + "group": "inline" + }, { "command": "taskExplorer.runWithArgs", "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showExecuteWithArgumentsButton && view == taskExplorer && viewItem == scriptFile", "group": "inline" }, + { + "command": "taskExplorer.runWithArgs", + "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showExecuteWithArgumentsButton && view == taskExplorer && viewItem == scriptFileS", + "group": "inline" + }, + { + "command": "taskExplorer.runWithArgs", + "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showExecuteWithArgumentsButton && view == taskExplorer && viewItem == scriptFileS", + "group": "inline" + }, { "command": "taskExplorer.run", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == script", @@ -696,6 +795,16 @@ "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFile", "group": "inline" }, + { + "command": "taskExplorer.run", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptS", + "group": "inline" + }, + { + "command": "taskExplorer.run", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFileS", + "group": "inline" + }, { "command": "taskExplorer.open", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == script", @@ -711,26 +820,61 @@ "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorer.open", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptS", + "group": "inline" + }, + { + "command": "taskExplorer.open", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptFileS", + "group": "inline" + }, + { + "command": "taskExplorer.open", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorer.openTerminal", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorer.openTerminal", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorer.restart", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorer.restart", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorer.pause", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorer.pause", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorer.stop", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorer.stop", + "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorer.addRemoveFromFavorites", "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showFavoritesButton && view == taskExplorer && viewItem == script", @@ -746,6 +890,21 @@ "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showFavoritesButton && view == taskExplorer && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorer.addRemoveFromFavorites", + "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showFavoritesButton && view == taskExplorer && viewItem == scriptS", + "group": "inline" + }, + { + "command": "taskExplorer.addRemoveFromFavorites", + "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showFavoritesButton && view == taskExplorer && viewItem == scriptFileS", + "group": "inline" + }, + { + "command": "taskExplorer.addRemoveFromFavorites", + "when": "config.taskExplorer.enableExplorerView && config.taskExplorer.showFavoritesButton && view == taskExplorer && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorer.clearSpecialFolder", "when": "config.taskExplorer.enableExplorerView && view == taskExplorer && viewItem == favorites", @@ -788,6 +947,18 @@ "command": "taskExplorerSideBar.open", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunning" }, + { + "command": "taskExplorerSideBar.open", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptS" + }, + { + "command": "taskExplorerSideBar.open", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFileS" + }, + { + "command": "taskExplorerSideBar.open", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunningS" + }, { "command": "taskExplorerSideBar.run", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == script" @@ -796,10 +967,22 @@ "command": "taskExplorerSideBar.run", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFile" }, + { + "command": "taskExplorerSideBar.run", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptS" + }, + { + "command": "taskExplorerSideBar.run", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFileS" + }, { "command": "taskExplorer.runWithArgs", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFile" }, + { + "command": "taskExplorer.runWithArgs", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFileS" + }, { "command": "taskExplorer.runNoTerm", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == script" @@ -808,6 +991,14 @@ "command": "taskExplorer.runNoTerm", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFile" }, + { + "command": "taskExplorer.runNoTerm", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptS" + }, + { + "command": "taskExplorer.runNoTerm", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFileS" + }, { "command": "taskExplorerSideBar.addToExcludes", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == taskFileApp-publisher" @@ -945,11 +1136,35 @@ "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunning" }, { - "command": "taskExplorer.clearSpecialFolder", + "command": "taskExplorerSideBar.addRemoveFromFavorites", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptS" + }, + { + "command": "taskExplorerSideBar.addRemoveFromFavorites", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFileS" + }, + { + "command": "taskExplorerSideBar.addRemoveFromFavorites", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunningS" + }, + { + "command": "taskExplorerSideBar.renameSpecial", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptS" + }, + { + "command": "taskExplorerSideBar.renameSpecial", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFileS" + }, + { + "command": "taskExplorerSideBar.renameSpecial", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunningS" + }, + { + "command": "taskExplorerSideBar.clearSpecialFolder", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == favorites" }, { - "command": "taskExplorer.clearSpecialFolder", + "command": "taskExplorerSideBar.clearSpecialFolder", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == lasttasks" }, { @@ -962,6 +1177,16 @@ "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFile", "group": "inline" }, + { + "command": "taskExplorerSideBar.run", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptS", + "group": "inline" + }, + { + "command": "taskExplorerSideBar.run", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFileS", + "group": "inline" + }, { "command": "taskExplorerSideBar.runNoTerm", "when": "config.taskExplorer.enableSideBar && config.taskExplorer.showExecuteWithNoTerminalButton && view == taskExplorerSideBar && viewItem == script", @@ -972,11 +1197,26 @@ "when": "config.taskExplorer.enableSideBar && config.taskExplorer.showExecuteWithNoTerminalButton && view == taskExplorerSideBar && viewItem == scriptFile", "group": "inline" }, + { + "command": "taskExplorerSideBar.runNoTerm", + "when": "config.taskExplorer.enableSideBar && config.taskExplorer.showExecuteWithNoTerminalButton && view == taskExplorerSideBar && viewItem == scriptS", + "group": "inline" + }, + { + "command": "taskExplorerSideBar.runNoTerm", + "when": "config.taskExplorer.enableSideBar && config.taskExplorer.showExecuteWithNoTerminalButton && view == taskExplorerSideBar && viewItem == scriptFileS", + "group": "inline" + }, { "command": "taskExplorerSideBar.runWithArgs", "when": "config.taskExplorer.enableSideBar && config.taskExplorer.showExecuteWithArgumentsButton && view == taskExplorerSideBar && viewItem == scriptFile", "group": "inline" }, + { + "command": "taskExplorerSideBar.runWithArgs", + "when": "config.taskExplorer.enableSideBar && config.taskExplorer.showExecuteWithArgumentsButton && view == taskExplorerSideBar && viewItem == scriptFileS", + "group": "inline" + }, { "command": "taskExplorerSideBar.open", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == script", @@ -992,26 +1232,61 @@ "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorerSideBar.open", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptS", + "group": "inline" + }, + { + "command": "taskExplorerSideBar.open", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptFileS", + "group": "inline" + }, + { + "command": "taskExplorerSideBar.open", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorerSideBar.openTerminal", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorerSideBar.openTerminal", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorerSideBar.restart", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorerSideBar.restart", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorerSideBar.pause", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorerSideBar.pause", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorerSideBar.stop", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorerSideBar.stop", + "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorerSideBar.addRemoveFromFavorites", "when": "config.taskExplorer.enableSideBar && config.taskExplorer.showFavoritesButton && view == taskExplorerSideBar && viewItem == script", @@ -1027,6 +1302,21 @@ "when": "config.taskExplorer.enableSideBar && config.taskExplorer.showFavoritesButton && view == taskExplorerSideBar && viewItem == scriptRunning", "group": "inline" }, + { + "command": "taskExplorerSideBar.addRemoveFromFavorites", + "when": "config.taskExplorer.enableSideBar && config.taskExplorer.showFavoritesButton && view == taskExplorerSideBar && viewItem == scriptS", + "group": "inline" + }, + { + "command": "taskExplorerSideBar.addRemoveFromFavorites", + "when": "config.taskExplorer.enableSideBar && config.taskExplorer.showFavoritesButton && view == taskExplorerSideBar && viewItem == scriptFileS", + "group": "inline" + }, + { + "command": "taskExplorerSideBar.addRemoveFromFavorites", + "when": "config.taskExplorer.enableSideBar && config.taskExplorer.showFavoritesButton && view == taskExplorerSideBar && viewItem == scriptRunningS", + "group": "inline" + }, { "command": "taskExplorerSideBar.clearSpecialFolder", "when": "config.taskExplorer.enableSideBar && view == taskExplorerSideBar && viewItem == favorites", @@ -1418,7 +1708,7 @@ "title": "%config.taskExplorer.useGulp%", "description": "%config.taskExplorer.useGulpDsc%" }, - "taskExplorer.rename": { + "taskExplorer.renameSpecial": { "type": "array", "items": { "type": "array", @@ -1427,7 +1717,7 @@ } }, "default": [], - "description": "%config.taskExplorer.rename%" + "description": "%config.taskExplorer.renameSpecial%" } } }, diff --git a/package.nls.json b/package.nls.json index 7782f55bb..12e647124 100644 --- a/package.nls.json +++ b/package.nls.json @@ -113,7 +113,7 @@ "config.taskExplorer.enableExplorerView": "Add a task explorer tray in the Explorer sidebar view.", - "config.taskExplorer.rename": "Configure labels that should be used in the Special Folders.", + "config.taskExplorer.renameSpecial": "Configure labels that should be used in the Special Folders.", "config.taskExplorer.showLastTasks": "Show the 'last tasks' as a node in the task tree.", "config.taskExplorer.showRunningTask": "Show the last ran running task in the status bar.", @@ -132,7 +132,7 @@ "taskdef.task.uri": "The uri of the task file.", "taskdef.task.taskItemId": "The tree item id that the task is associated with.", "taskdef.task.isDefault": "For Ant tasks, indicates the 'default' task.", - "taskdef.task.scriptType": "The type of script (bash, batch, pythin, etc...).", + "taskdef.task.scriptType": "The type of script (bash, batch, python, etc...).", "taskdef.task.cmdLine": "The command line used to execute the script in a shell.", "taskdef.task.scriptFile": "Boolean to display filename as the script target. Set to true.", "taskdef.task.takesArgs": "Boolean to indicate if the script accepts command line args.", @@ -153,6 +153,7 @@ "command.debug": "Debugging ", "command.open": "Open", "command.openTerminal": "Open Terminal", + "command.renameSpecial": "Add/Remove special folders label", "command.runInstall": "Run pkg mgr install", "command.runAudit": "Run pkg mgr audit", "command.runAuditFix": "Run pkg mgr audit fix", diff --git a/src/common/utils.ts b/src/common/utils.ts index 31dab9be7..dff4145d5 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -8,6 +8,7 @@ import constants from "./constants"; import * as path from "path"; import * as os from "os"; import * as log from "./log"; +import TaskItem from "../tree/item"; /** @@ -281,6 +282,14 @@ export function getScriptProviderType(source: string): string } +export function getTaskItemId(taskItem: TaskItem) +{ + return taskItem?.id?.replace(constants.LAST_TASKS_LABEL + ":", "") + .replace(constants.FAV_TASKS_LABEL + ":", "") + .replace(constants.USER_TASKS_LABEL + ":", ""); +} + + export function isExcluded(uriPath: string, logPad = "") { function testForExclusionPattern(path: string, pattern: string): boolean diff --git a/src/tree/item.ts b/src/tree/item.ts index 7a6116924..0239fee89 100644 --- a/src/tree/item.ts +++ b/src/tree/item.ts @@ -6,6 +6,8 @@ from "vscode"; import * as path from "path"; import TaskFile from "./file"; import * as util from "../common/utils"; +import { storage } from "../common/storage"; +import constants from "../common/constants"; /** @@ -137,7 +139,21 @@ export default class TaskItem extends TreeItem setContextValue(task: Task, running: boolean) - { // + { + const favTasks = storage.get(constants.FAV_TASKS_STORE, []), + lastTasks = storage.get(constants.LAST_TASKS_STORE, []), + id = util.getTaskItemId(this); + + if (util.existsInArray(favTasks, id) || util.existsInArray(lastTasks, id)) + { + if (task.definition.scriptFile || this.taskSource === "gradle") { + this.contextValue = running ? "scriptSRunning" : "scriptFileS"; + } + else { + this.contextValue = running ? "scriptSRunning" : "scriptS"; + } + } + // // Context view controls the view parameters to the ui, see package.json /views/context node. // // script - Standard task item, e.g. "npm", "Workspace", "gulp", etc @@ -147,11 +163,14 @@ export default class TaskItem extends TreeItem // Note that TaskItems of type 'scriptFile' can be ran with arguments and this will have an additional // entry added to it's context menu - "Run with arguments" // - if (task.definition.scriptFile || this.taskSource === "gradle") { - this.contextValue = running ? "scriptRunning" : "scriptFile"; - } - else { - this.contextValue = running ? "scriptRunning" : "script"; + else + { + if (task.definition.scriptFile || this.taskSource === "gradle") { + this.contextValue = running ? "scriptRunning" : "scriptFile"; + } + else { + this.contextValue = running ? "scriptRunning" : "script"; + } } } diff --git a/src/tree/tree.ts b/src/tree/tree.ts index a52850acc..1f126cfa8 100644 --- a/src/tree/tree.ts +++ b/src/tree/tree.ts @@ -77,6 +77,7 @@ export class TaskTreeDataProvider implements TreeDataProvider subscriptions.push(commands.registerCommand(name + ".addToExcludes", async (taskFile: TaskFile | string) => { await this.addToExcludes(taskFile); }, this)); subscriptions.push(commands.registerCommand(name + ".addRemoveFromFavorites", async (taskItem: TaskItem) => { await this.addRemoveFavorite(taskItem); }, this)); subscriptions.push(commands.registerCommand(name + ".clearSpecialFolder", async (taskFolder: TaskFolder) => { await this.clearSpecialFolder(taskFolder); }, this)); + subscriptions.push(commands.registerCommand(name + ".renameSpecial", async (taskItem: TaskItem) => { await this.renameSpecial(taskItem); }, this)); tasks.onDidStartTask(async (_e) => this.taskStartEvent(_e)); tasks.onDidEndTask(async (_e) => this.taskFinishedEvent(_e)); @@ -95,7 +96,7 @@ export class TaskTreeDataProvider implements TreeDataProvider private async addRemoveFavorite(taskItem: TaskItem) { const favTasks = storage.get(constants.FAV_TASKS_STORE, []); - const favId = this.getTaskItemId(taskItem); + const favId = util.getTaskItemId(taskItem); log.methodStart("add/remove favorite", 1, "", false, [ ["id", taskItem.id ], [ "current fav count", favTasks.length ] @@ -126,6 +127,56 @@ export class TaskTreeDataProvider implements TreeDataProvider } + private async renameSpecial(taskItem: TaskItem) + { + let addRemoved = false, + index = 0; + const renames: string[][] = configuration.get("renameSpecial", []), + id = util.getTaskItemId(taskItem); + + log.methodStart("add/remove rename special", 1, "", false, [["id", id]]); + + if (!id) { + return; + } + + for (const i in renames) + { + if (id === renames[i][0]) + { + addRemoved = true; + renames.splice(index, 1); + break; + } + ++index; + } + + if (!addRemoved) + { + const opts: InputBoxOptions = { prompt: "Enter favorites label" }; + await window.showInputBox(opts).then(async (str) => + { + if (id && str !== undefined) + { + addRemoved = true; + renames.push([id, str]); + } + }); + } + + // + // Update + // + if (addRemoved) { + await configuration.update("renameSpecial", renames); + await this.showSpecialTasks(true, true, undefined, " "); + await this.showSpecialTasks(true, false, undefined, " "); + } + + log.methodDone("add/remove rename special", 1); + } + + private async addToExcludes(selection: TaskFile | string) { const me = this; @@ -902,7 +953,7 @@ export class TaskTreeDataProvider implements TreeDataProvider if (configuration.get("showLastTasks") === true) { const lastTasks = storage.get(constants.LAST_TASKS_STORE, []); - if (util.existsInArray(lastTasks, this.getTaskItemId(taskItem)) !== false) + if (util.existsInArray(lastTasks, util.getTaskItemId(taskItem)) !== false) { if (this.taskTree[0].label === constants.LAST_TASKS_LABEL) { @@ -915,7 +966,7 @@ export class TaskTreeDataProvider implements TreeDataProvider // Fire change event for the 'Favorites' folder if the task exists there // const favTasks = storage.get(constants.FAV_TASKS_STORE, []); - if (util.existsInArray(favTasks, this.getTaskItemId(taskItem)) !== false) + if (util.existsInArray(favTasks, util.getTaskItemId(taskItem)) !== false) { if (this.taskTree[0].label === constants.FAV_TASKS_LABEL) { @@ -1140,11 +1191,14 @@ export class TaskTreeDataProvider implements TreeDataProvider private getSpecialTaskName(taskItem: TaskItem) { let label = taskItem.taskFile.folder.label + " - " + taskItem.taskSource; - const renames: string[][] = configuration.get("rename"); + const renames: string[][] = configuration.get("renameSpecial"), + id = util.getTaskItemId(taskItem); for (const i in renames) { - if (taskItem.resourceUri?.fsPath === renames[i][0] && renames[i][1]) { - label = renames[1][1]; + if (id === renames[i][0]) + { + label = renames[i][1]; + break; } } return taskItem.label + " (" + label + ")"; @@ -1370,14 +1424,6 @@ export class TaskTreeDataProvider implements TreeDataProvider } - private getTaskItemId(taskItem: TaskItem) - { - return taskItem?.id?.replace(constants.LAST_TASKS_LABEL + ":", "") - .replace(constants.FAV_TASKS_LABEL + ":", "") - .replace(constants.USER_TASKS_LABEL + ":", ""); - } - - private getTerminal(taskItem: TaskItem, logPad = ""): Terminal | undefined { const me = this; @@ -1853,7 +1899,7 @@ export class TaskTreeDataProvider implements TreeDataProvider { let taskItem2: TaskItem | undefined; const ltFolder = this.taskTree ? this.taskTree[treeIndex] as TaskFolder : undefined; - const taskId = label + ":" + this.getTaskItemId(taskItem); + const taskId = label + ":" + util.getTaskItemId(taskItem); if (!ltFolder || !taskItem.task) { return; @@ -2414,7 +2460,7 @@ export class TaskTreeDataProvider implements TreeDataProvider const storeName: string = !isFavorite ? constants.LAST_TASKS_STORE : constants.FAV_TASKS_STORE; const label: string = !isFavorite ? constants.LAST_TASKS_LABEL : constants.FAV_TASKS_LABEL; const cstTasks = storage.get(storeName, []); - const taskId = this.getTaskItemId(taskItem); + const taskId = util.getTaskItemId(taskItem); log.methodStart("save task", 1, logPad, false, [ [ "treenode label", label ], [ "max tasks", maxTasks ], [ "is favorite", isFavorite ],