-
Notifications
You must be signed in to change notification settings - Fork 512
Add status bar notification when PowerShell is running #1227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add status bar notification when PowerShell is running #1227
Conversation
src/features/Console.ts
Outdated
break; | ||
|
||
// If the execution has stopped, destroy the previous notification | ||
case ExecutionStatus.Completed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does tslint not yell at you for missing the break statement in cases? That's surprising to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think so. It's set to error on any linting warnings, so it shouldn't have compiled if it did. I'll add it in though -- I recall thinking about it (and wondering why tslint didn't care), but I must have forgotten to put it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, you mean tslint shouldn't allow fallthrough? I would have put default
but I want to ignore ExecutionStatus.Pending
. So fallthrough seemed to match my needs best. Do we want to avoid that? I can change if so 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh. I'm fine with fallthrough but I know it's controversial so I was surprised :)
VSCode added a progress api not too long ago. I was messing with it to fix Write-Progress not showing up (never finished that work though). It seemed like it works pretty well so we probably don't need to use the custom class of ours, we can use the new API (supported in 1.12 and higher which isn't a problem at all). Eventually, for anything "progress" related, we can stick to using this API. Thoughts? Oh and the text in the progress API goes exactly where @rjmholt's text is in that gif. |
Here's an example of the progress API: vscode.window.withProgress({ location: vscode.ProgressLocation.Window, title: 'hello'}, p => {
return new Promise((resolve, reject) => {
p.report({message: 'Start working...' });
let count= 0;
let handle = setInterval(() => {
count++;
p.report({message: 'Worked ' + count + ' steps' });
if (count >= 10) {
clearInterval(handle);
resolve();
}
}, 1000);
});
}); |
The text is the part I'm least happy with -- just not familiar with VSCode APIs. But if we could get a richer indicator or a progress bar or a colour change (something you would notice in the corner of your eye), that would make me happier. |
Might possibly be worth refactoring in light of this SO answer. Currently I export the Thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick question and a few nitpicks :)
src/features/Console.ts
Outdated
import { LanguageClient, NotificationType, RequestType } from "vscode-languageclient"; | ||
import { ICheckboxQuickPickItem, showCheckboxQuickPick } from "../controls/checkboxQuickPick"; | ||
import { IFeature } from "../feature"; | ||
|
||
import * as AnimatedStatusBar from "../controls/animatedStatusBar"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we don't need this anymore, right?
src/features/Console.ts
Outdated
@@ -3,12 +3,17 @@ | |||
*--------------------------------------------------------*/ | |||
|
|||
import vscode = require("vscode"); | |||
import { Disposable } from "vscode-jsonrpc"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we don't need this anymore, right?
src/features/Console.ts
Outdated
case ExecutionStatus.Completed: | ||
case ExecutionStatus.Aborted: | ||
case ExecutionStatus.Failed: | ||
this.resolveStatusBarPromise(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if for whatever reason... vscode powershell doesn't get the ExecutionStatus.Running message but it gets the ExecutionStatus.Completed message... will this line throw an error if this.resolveStatusBarPromise
takes the default value?
So it looks like you could change the color if we could get the StatusBarItem object of the progress: but I'm not sure if that's possible. |
Add a notification listener for execution status events from the Language Server (Running, Completed, etc) and alter the status bar to inform the user when PowerShell is executing a script.
f407709
to
13ef63b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 I'll leave it open for a day or so to see if anyone one else wants to take a look.
My only thought on this was that perhaps this execution status should be displayed as part of the current PowerShell status bar info (version / session menu). That said, that status disappears when you select a file that isn't a PowerShell script file. |
@rkeithhill that, and I think we wouldn't be able to use the Progress API because the Progress API adds a little spinner. That'd get really annoying if that was there constantly. |
Long live the spinner! 🔁 |
Coupled with PowerShellEditorServices #632, this adds a status bar item for when PowerShell is executing, indicating to the user that something is running.
Demo:
