-
Notifications
You must be signed in to change notification settings - Fork 92
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 actions for executing code #2684
Conversation
bfd8857
to
9169c36
Compare
9169c36
to
55445a6
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.
That's going to be so useful!
src/vs/workbench/contrib/languageRuntime/browser/languageRuntimeActions.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/languageRuntime/browser/languageRuntimeActions.ts
Outdated
Show resolved
Hide resolved
}); | ||
|
||
/** | ||
* Execute Code Silently: executes code, but doesn't show it to the user. |
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.
Doc: This action executes code immediately after the currently running command (if any) has finished. It has priority over the queue of pending console inputs from the user but still needs to wait until the current command is finished, which might take a long time.
Any output (messages, warnings, or errors) generated by this command is discarded silently instead of being shown in the console.
I'm playing with this now and want to leave a few more notes for test driving:
I am also in some unhappy state w.r.t. Python right now and the above snippet works simply by substituting 'r' for 'python' in |
I just had a lovely time with this:
This gives me an experience similar to what I enjoy in RStudio, where (1) |
Possibly silly example, but this works for an active R console (didn't try Python due to unhappy situation mentioned above):
|
Here's a good example for experiencing
Here's me printing
|
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.
A few straightforward experiments worked and I think this is great!
Because of the example I chose (messing with significant digits), I used the "Restart console" button in the R console, which dutifully restarted the console. But now when I invoke the keyboard shortcut (Cmd + Shift + J, in the case of that example), I see this
But there is definitely an active R console. The other keybindings are still working, which suggests the problem is specific to workbench.action.executeCode.silently
.
I spent some time trying to reproduce this and found that this is a bug in the code that tracks console sessions; fixed in 7b08b7b. |
Intent
Make it possible to create keybindings that run code in Positron. This feature has been requested frequently by both private beta and internal beta users.
Addresses #2375
Addresses #2661
Approach
There are two new commands here; they have arguments and semantics that are different enough to warrant the bifurcation.
workbench.action.executeCode.console
- executes code as if the user typed it. This is useful for keybindings that are used more like macros.workbench.action.executeCode.silently
- executes code silently. This is useful for code that is run for its side effects (e.g. making API calls).Both commands accept an argument object that can specify
langId
andcode
fields. They can also accept just a plain string as an argument, in which case the code will be run in whatever console happens to be active.QA Notes
Here is an example keybinding to start playing with this:
Try: