PowerShell / PowerShell/vscode-powershell

Feature Request: Call VSCode commands from $psEditor variable

Open
#804 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-psEditor Issue-Enhancement
Dominant language
TypeScript
Stars
1.9k
Forks
547
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the built-in $psEditor EditorObject API, especially its Workspace, Window, GetEditorContext(), RegisterCommand(), and UnregisterCommand() members, and compare the broader request with related issue #773. Done means a PowerShell script in the VSCode-PowerShell environment can invoke VSCode commands through $psEditor.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, typescript, vscode
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.