Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all issues to ensure it has not already been reported.
Summary
I am migrating from the old powershell_ISE to powershell 7. One thing I used to do a LOT in the ps ISE world is a non-IDE-initiated Go-To-Definition. This was implemented as a command (i.e. Def MyFunction, if inside ISE, then it just opens there and sets the cursor to the position; if outside the ISE then it would open the ISE and set the cursor position there)
In the VSCode plugin, there is F12/Go-to-Definition in the UI, but I seem to be blocked from implementing it in command form (or I can’t find it). I did find “Open-EditorFile” which is close, but it does not allow me to point to a specific line, the way I could with the powershell_ise. In particular, $psise.CurrentFile.Editor.SetCaretPosition could be used to fine-tune where the cursor is pointing, but the $psEditor object seems to be highly restricted.
Would it be possible to get a feature to $psEditor.Workspace to have a function to open / jump to a given file+line? E.g. OpenFile(string filePath, uint32 lineNumber, uint32 columnNumber)
? Allowing the user to 'pop' any file and line number they want is always going to be the most capable option, allowing people to jump to code that may be too obscurely done for the mainstream ISE to ever track.
(optionally, also add a psEditor.WorkSpace.GoToDefinition
which more directly mirrors the existing UI option)
Proposed Design
Please add a new overload for $psEditor.Workspace.OpenFile, such as OpenFile(string filePath, uint32 **lineNumber**, uint32 columnNumber)
(Also expose this overload in the CmdletInterface.ps1 file.)
Optionally, also add psEditor.WorkSpace.GoToDefinition(string identifier)
and expose that in the CmdletInterface.ps1 as well.