Skip to content

Fix for #49138#49501

Merged
ramya-rao-a merged 3 commits intomicrosoft:masterfrom
jeanp413:fix49138
May 14, 2018
Merged

Fix for #49138#49501
ramya-rao-a merged 3 commits intomicrosoft:masterfrom
jeanp413:fix49138

Conversation

@jeanp413
Copy link
Copy Markdown
Contributor

@jeanp413 jeanp413 commented May 9, 2018

Fixes issue #49138

@ramya-rao-a
Copy link
Copy Markdown
Contributor

@gushuro Do you want to take a look at this first before I dive in?

@gushuro
Copy link
Copy Markdown
Contributor

gushuro commented May 10, 2018

Sure!

Copy link
Copy Markdown
Contributor

@gushuro gushuro left a comment

Choose a reason for hiding this comment

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

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above.

Copy link
Copy Markdown
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

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

Thanks @jeanp413

@ramya-rao-a ramya-rao-a added this to the May 2018 milestone May 14, 2018
@ramya-rao-a ramya-rao-a merged commit 7f27412 into microsoft:master May 14, 2018
@jeanp413 jeanp413 deleted the fix49138 branch May 14, 2018 05:32
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants