Fix for #49138#49501
Merged
ramya-rao-a merged 3 commits intomicrosoft:masterfrom May 14, 2018
Merged
Conversation
Contributor
|
@gushuro Do you want to take a look at this first before I dive in? |
Contributor
|
Sure! |
gushuro
reviewed
May 11, 2018
Contributor
gushuro
left a comment
There was a problem hiding this comment.
Besides a couple small comments, LGTM
Tested a few cases and it works fine.
| // If newPreviewLineEnd is equal to the previous expandedText lineEnd, | ||
| // set newPreviewStart to the length of the previous expandedText in that line | ||
| // plus the number of characters between both selections. | ||
| newPreviewStart = charactersInLine.count + (oldPreviewRange.start.character - lastOldPreviewRange.end.character); |
Contributor
There was a problem hiding this comment.
On the first iteration, lastOldPreviewRange is not assigned yet. On that iteration it won't hit this if condition, but I'd add a safety check here anyway (or assign a dummy range to it on line 119).
| function applyPreview(expandAbbrList: ExpandAbbreviationInput[]): Thenable<boolean> { | ||
| let lastOldPreviewRange: vscode.Range; | ||
| let totalLinesInserted = 0; | ||
| let charactersInLine = { line: -1, count: 0 }; |
Contributor
There was a problem hiding this comment.
Consider renaming this for readability
| } | ||
| else if (newPreviewLineStart === charactersInLine.line) { | ||
| // Same as above but expandedTextLines.length > 1 so newPreviewEnd keeps its value. | ||
| newPreviewStart = charactersInLine.count + (oldPreviewRange.start.character - lastOldPreviewRange.end.character); |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes issue #49138