Skip to content

Feature Request: Call VSCode commands from $psEditor variable #804

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

Open
pcgeek86 opened this issue May 31, 2017 · 4 comments
Open

Feature Request: Call VSCode commands from $psEditor variable #804

pcgeek86 opened this issue May 31, 2017 · 4 comments
Labels
Area-psEditor Issue-Enhancement A feature request (enhancement).

Comments

@pcgeek86
Copy link
Contributor

It would be really cool if a PowerShell script were able to invoke VSCode commands, effectively automating the IDE from PowerShell. This could be exposed via the built-in $psEditor variable that's accessible in the VSCode-PowerShell environment.

Related to #773, but more broad.

If there's already a way to do this, I'd love to hear it. I've explored the Workspace and Window variables on the $psEditor object, along with the GetEditorContext() method output, and can't find any way to do this right now.

PS /Users/tsulli> $psEditor |gm

   TypeName: Microsoft.PowerShell.EditorServices.Extensions.EditorObject

Name                  MemberType Definition
----                  ---------- ----------
Equals                Method     bool Equals(System.Object obj)
GetEditorContext      Method     Microsoft.PowerShell.EditorServices.Extensions.EditorContext GetEditorContext()
GetHashCode           Method     int GetHashCode()
GetType               Method     type GetType()
RegisterCommand       Method     bool RegisterCommand(Microsoft.PowerShell.EditorServices.Extensions.EditorCommand editorCommand)
ToString              Method     string ToString()
UnregisterCommand     Method     void UnregisterCommand(string commandName)
EditorServicesVersion Property   version EditorServicesVersion {get;}
Window                Property   Microsoft.PowerShell.EditorServices.Extensions.EditorWindow Window {get;}
Workspace             Property   Microsoft.PowerShell.EditorServices.Extensions.EditorWorkspace Workspace {get;}

Cheers,
Trevor Sullivan

@pcgeek86 pcgeek86 added Area-psEditor Issue-Enhancement A feature request (enhancement). labels May 31, 2017
@daviwil
Copy link
Contributor

daviwil commented Jun 1, 2017

Hey Trevor! Sorry for the delay. Yep, we'll provide a way to invoke the editor's native commands.

@daviwil daviwil added this to the June 2017 milestone Jun 1, 2017
@mattmcnabb
Copy link
Contributor

So would tasks be able to leverage these native commands? Or only from the Integrated Console? I'd love to be able to run my test task and automatically shoot the view over to the Problems pane when the tests complete. I'm sure there are some other use cases for accessing these commands from a task as well.

@daviwil
Copy link
Contributor

daviwil commented Jun 1, 2017

Tasks are a different story since they're running in a fresh PowerShell instance that doesn't have any connection to the Editor Services session. This might be a case where VS Code's tasks.json schema should give you the option on what pane should be opened after a task completes, worth filing a feature request since they're doing some major reworking of that format right now.

@mattmcnabb
Copy link
Contributor

That's a good idea - i posted an issue here #27960

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-psEditor Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

5 participants