Skip to content

Catch ArgumentOutOfRange exception #583

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

Merged

Conversation

TylerLeonhardt
Copy link
Member

fixes #582

IScriptExtent throws an ArgumentOutOfRangeException. When accessing the Text property.

This PR catches that error and sets it to a default value of empty string.

Copy link
Contributor

@rkeithhill rkeithhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}
catch (ArgumentOutOfRangeException e)
{
scriptExtentText = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One general "best practice" in C# is when you need to use an empty string, use string.Empty instead of "". I think it might save an allocation, but it's not that big of a deal if you don't do it.

@TylerLeonhardt TylerLeonhardt merged commit 3ca4139 into PowerShell:master Dec 6, 2017
@TylerLeonhardt TylerLeonhardt deleted the issue582-large-number-crash branch December 6, 2017 23:49
TylerLeonhardt pushed a commit to TylerLeonhardt/PowerShellEditorServices that referenced this pull request Feb 26, 2019
This change enables the saving of files opened from a remote session using
the psedit command.  When the editor saves the file contents it sends a
DidSaveTextDocumentNotification to the language server which in turn sends
the document's contents back to the remote session to be saved in the
original file.

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

Successfully merging this pull request may close these issues.

Very Large String crashes PS Editor Services
3 participants