Skip to content

New-EditorFile FileName.ps1 fails with Exception calling "GetEditorContext" with "0" argument(s): "One or more errors occurred. (Exception of type 'OmniSharp.Extensions.JsonRpc.Server.JsonRpcException' was thrown.)" #3180

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

Closed
AlejoSQL opened this issue Feb 12, 2021 · 2 comments · Fixed by PowerShell/PowerShellEditorServices#1411
Labels

Comments

@AlejoSQL
Copy link

AlejoSQL commented Feb 12, 2021

System Details

System Details Output

PowerShell extension for Azure Data Studio fails when creating a new file. 


Azure data studio Version: 1.25.3 (user setup)
Commit: b277eafb8f5328ea26c6edfddd1999292ac27937
Date: 2021-02-09T23:10:35.151Z
VS Code: 1.48.0
Electron: 9.4.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.18363

Issue Description

I am experiencing a problem with...

Trying to create a new ps file from within Azure data studio

Expected Behaviour

-- Create a file :)

Actual Behaviour

-- Error thrown

.azuredatastudio\extensions\microsoft.powershell-2020.4.0\modules\PowerShellEditorServices\Commands\Public\CmdletInterface.ps1:128:9
$editorContext = $psEditor.GetEditorContext()

Exception calling "GetEditorContext" with "0" argument(s): "One or more errors occurred. (Exception of type 'OmniSharp.Extensions.JsonRpc.Server.JsonRpcException' was thrown.)"

Attached Logs

Follow the instructions in the troubleshooting docs
about capturing and sending logs.

@ghost ghost added the Needs: Triage Maintainer attention needed! label Feb 12, 2021
@corbob
Copy link
Contributor

corbob commented Feb 13, 2021

🤔 I didn't even know about this command 🤷‍♂️

However, I can reproduce this in preview extension 2020.9.0 and vscode insiders.

@corbob
Copy link
Contributor

corbob commented Feb 13, 2021

Well this is fun...

I ran Set-PSBreakpoint -Command New-EditorFile, stepped through the code and investigated the $pseditor object, then couldn't reproduce the error... Now I can't reproduce it at all under either Windows PowerShell or PowerShell 7 🤦‍♂️

Edit:

Reproduction steps (and a workaround for @AlejoSQL ):

It would seem that there is no Editor Context when there is no editor window open (which thinking about it makes sense). Notice in the gif the error happens, then I open a new Untitled-1 file, and now the command works as expected.

new-editorfile

A fix might be to move the context code later in the function after we've created and opened the file. This should guarantee we have a context (although there's notes about a temp session that might preclude it in that scenario)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants