Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelog

### Version 2.2.1

- Add "Restart" button alongside "Stop" button for running scripts to stop and restart the script
- Replace stop button text with a stop icon ($(debug-stop))
- Fix clicking a running task to stop it immediately instead of queuing a new start

### Version 2.2.0

- Performance improvement to cache package information
Expand Down
19 changes: 17 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "webnative",
"displayName": "WebNative",
"description": "Create and maintain web and native projects",
"version": "2.2.0",
"version": "2.2.1",
"whatsNewRevision": 1,
"icon": "media/webnative.png",
"publisher": "WebNative",
Expand Down Expand Up @@ -292,7 +292,13 @@
},
{
"command": "webnative.stop",
"title": "Stop"
"title": "Stop",
"icon": "$(debug-stop)"
},
{
"command": "webnative.restart",
"title": "Restart",
"icon": "$(debug-restart)"
},
{
"command": "webnative.buildConfig",
Expand Down Expand Up @@ -485,6 +491,10 @@
{
"command": "webnative.stop",
"when": "false"
},
{
"command": "webnative.restart",
"when": "false"
}
],
"view/title": [
Expand Down Expand Up @@ -515,6 +525,11 @@
"when": "view == wn-tree && viewItem == stop",
"group": "inline"
},
{
"command": "webnative.restart",
"when": "view == wn-tree && viewItem == stop",
"group": "inline"
},
{
"command": "webnative.open",
"when": "view == wn-tree && viewItem == asset",
Expand Down
1 change: 1 addition & 0 deletions src/command-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum CommandName {
Refresh = 'webnative.refresh',
Add = 'webnative.add',
Stop = 'webnative.stop',
Restart = 'webnative.restart',
Rebuild = 'webnative.rebuild',
RefreshDebug = 'webnative.refreshDebug',
Function = 'webnative.function',
Expand Down
12 changes: 12 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ export async function activate(context: ExtensionContext) {
recommendation.setContext(undefined);
});

commands.registerCommand(CommandName.Restart, async (recommendation: Recommendation) => {
const tip = recommendation.tip;
// Stop the running task
tip.data = Context.stop;
await fixIssue(undefined, context.extensionPath, ionicProvider, tip);
recommendation.setContext(undefined);
// Clear the stop data flag and wait for the process to fully terminate before restarting
tip.data = undefined;
await new Promise((resolve) => setTimeout(resolve, 2000));
runAction(tip, ionicProvider, rootPath);
});

commands.registerCommand(CommandName.OpenInXCode, async () => {
await findAndRun(ionicProvider, rootPath, CommandTitle.OpenInXCode);
});
Expand Down
13 changes: 7 additions & 6 deletions src/features/fix-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,17 @@ async function execute(tip: Tip, context: ExtensionContext): Promise<void> {
}

export async function runAction(tip: Tip, ionicProvider: ExTreeProvider, rootPath: string, srcCommand?: CommandName) {
// If this task is already running, stop it immediately instead of queuing
if ((tip.stoppable || tip.contextValue == Context.stop) && isRunning(tip)) {
cancelIfRunning(tip);
markActionAsCancelled(tip);
ionicProvider.refresh();
return;
}
if (await waitForOtherActions(tip)) {
return; // Canceled
}
if (tip.stoppable || tip.contextValue == Context.stop) {
if (isRunning(tip)) {
cancelIfRunning(tip);
markActionAsCancelled(tip);
ionicProvider.refresh();
return;
}
markActionAsRunning(tip);
ionicProvider.refresh();
}
Expand Down
Loading