Skip to content
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

New-EditorFile triggers an error messsage #1210

Closed
alexandair opened this issue Feb 23, 2018 · 10 comments
Closed

New-EditorFile triggers an error messsage #1210

alexandair opened this issue Feb 23, 2018 · 10 comments
Labels
Area-psEditor Hackathon Up for grabs, especially at Hackathons! Issue-Bug A bug to squash. Up for Grabs Will shepherd PRs.

Comments

@alexandair
Copy link

PS C:\projects\TestPipeline> code -v
1.20.1
f88bbf9137d24d36d968ea6b2911786bfe103002
x64
PS C:\projects\TestPipeline> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      6      0      0


PS C:\projects\TestPipeline> code --list-extensions --show-versions
mauve.terraform@0.0.20
mindginative.terraform-snippets@2.0.1
ms-azuretools.vscode-azurestorage@0.2.0
ms-kubernetes-tools.vscode-kubernetes-tools@0.1.5
ms-vscode.azure-account@0.3.1
ms-vscode.azurecli@0.4.0
ms-vscode.PowerShell@1.6.0
ms-vsts.team@1.122.0
msazurermtools.azurerm-vscode-tools@0.4.0
octref.vscode-json-transform@0.1.2
pnp.polacode@0.2.2
vscoss.vscode-ansible@0.1.3
PS C:\projects\TestPipeline> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.16299.98
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.98
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

When I run New-EditorFile, a new file is created, but I also get an error message:

PS C:\projects\TestPipeline> New-EditorFile
Exception calling "GetEditorContext" with "0" argument(s): "One or more errors occurred."
At C:\Users\aleksandar\.vscode\extensions\ms-vscode.powershell-1.6.0\modules\PowerShellEditorServices\Commands\P
ublic\CmdletInterface.ps1:152 char:13
+             $psEditor.GetEditorContext().CurrentFile.InsertText(($val ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : AggregateException

Attached Logs

Follow the instructions in the README
about capturing and sending logs.

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Feb 23, 2018

Thanks for this! Interesting. Does that error happen when you run:

$psEditor.GetEditorContext()

In the integrated console?

@Benny1007
Copy link
Contributor

Does for me

:\MICROSOFT\PowerShell> $psEditor.GetEditorContext()
Exception calling "GetEditorContext" with "0" argument(s): "One or more errors occurred."
At line:1 char:1

  • $psEditor.GetEditorContext()
  •   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : AggregateException
    
    

I:\MICROSOFT\PowerShell> New-EditorFile
Exception calling "GetEditorContext" with "0" argument(s): "One or more errors occurred."
At C:\Users\bensh.vscode\extensions\ms-vscode.powershell-1.6.0\modules\PowerShellEditorServices\Commands\Public\CmdletInterface.ps1:152 char:13

  •         $psEditor.GetEditorContext().CurrentFile.InsertText(($val ...
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : AggregateException

@SeeminglyScience
Copy link
Collaborator

SeeminglyScience commented Feb 23, 2018

I can repro if I comment out "files.defaultLanguage": "powershell" from my settings.

@tylerl0706 there's an overload on openTextDocument that allows you to specify what language the new text document should be. If we just always set that to powershell it should resolve the issue.

btw this is probably a good one for the Hackathon :)

@TylerLeonhardt
Copy link
Member

Perfect for the hackathon!

@TylerLeonhardt TylerLeonhardt added the Hackathon Up for grabs, especially at Hackathons! label Feb 23, 2018
@TylerLeonhardt
Copy link
Member

Thanks for the report everyone!

@alexandair
Copy link
Author

$psEditor.GetEditorContext() works on my machine without a problem. New-EditorFile still fails.

@TylerLeonhardt
Copy link
Member

@alexandair, right if you have a PowerShell file open, and you run that, it should work. New-editorfile creates a new file, so if that file is not a PowerShell file, that call will error out.

@TylerLeonhardt TylerLeonhardt added the Issue-Bug A bug to squash. label Feb 26, 2018
@TylerLeonhardt
Copy link
Member

This only seems to happen with Untitled files... because:

Get-Process | New-EditorFile -Path foo.txt

works fine.

@TylerLeonhardt TylerLeonhardt added the Up for Grabs Will shepherd PRs. label Mar 20, 2018
@Benny1007
Copy link
Contributor

I can't reproduce this with the latest version of the extension.

@TylerLeonhardt
Copy link
Member

Ah yes this was fixed in #1580. We can close this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-psEditor Hackathon Up for grabs, especially at Hackathons! Issue-Bug A bug to squash. Up for Grabs Will shepherd PRs.
Projects
None yet
Development

No branches or pull requests

5 participants