-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Cleanup ArgumentOutOfRange exception for LSP.Range #68168
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chuck made a Comment in the other PR. Is the new argument resource string necessary? It looks like the caller in ProtocolConversions will catch the exception and wrap the exception in an exception that includes the line count.
That exception catching code is here, and was added by Cyrus. I've added an issue for removing it when this investigation is done. Without this code catching the exception and adding the line numbers, I think its useful to still throw an exception saying T
he requested line number {0} must be less than the number of lines {1}
Open to feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it seems useful to throw an
ArgumentOutOfRange
exception from TextLineCollection.LinePosition(), but I don't think we need a dedicated resource string for that case, particularly since the caller here is catching and wrapping the exception and including the line count.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catching code here will be removed when the investigation into these ArgumentOutOfRange exceptions is finished. When that code is removed there will not be logging for the total number of lines in the document.
Is there a cost to having a resource string here? It seems like an easy thing to add that will bring clarity to something that has been a point of confusion in the LSP spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically this catching code on line 211 should not stay here permanently because it hides the true cause of the ArgumentException. It should be removed once we round up the ArgumentOutOfRange exceptions.
We've already proven that for the case of end.Line == lines.Count it is difficult to determine the source of the error. We needed the logging on line 211 to do it. Additionally, given that the case of end.Line == lines.Count might not intuitively be seen an error, I believe that we should throw a very clear error message as to what has been done wrong.