Support the "reason" arg for trimming trailing whitespace#35778
Merged
alexdima merged 3 commits intomicrosoft:masterfrom Oct 24, 2017
Merged
Support the "reason" arg for trimming trailing whitespace#35778alexdima merged 3 commits intomicrosoft:masterfrom
alexdima merged 3 commits intomicrosoft:masterfrom
Conversation
jednano
suggested changes
Oct 7, 2017
| private preserveCursor: boolean; | ||
|
|
||
| constructor(selection: Selection) { | ||
| constructor(selection: Selection, preserveCursor?: boolean) { |
There was a problem hiding this comment.
Shouldn't it be preserving multiple cursors? Not just one?
Contributor
Author
There was a problem hiding this comment.
Yeah, I woke up realizing that passing a boolean was silly—I should just provide the cursors directly to the command. Fixed that.
|
|
||
| public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { | ||
| let ops = trimTrailingWhitespace(model, []); | ||
| var cursors: [Position]; |
There was a problem hiding this comment.
const cursors = (this.selection && this.preserveCursor)
? [new Position(this.selection.positionLineNumber, this.selection.positionColumn)]
: [Position]
;| private preserveCursor: boolean; | ||
|
|
||
| constructor(selection: Selection) { | ||
| constructor(selection: Selection, preserveCursor?: boolean) { |
There was a problem hiding this comment.
Consider preserveCursor = false here for a default value (makes it conditional).
jednano
approved these changes
Oct 8, 2017
Contributor
Author
|
Hi @alexandrudima! Is there any thing I can do to help get this in? |
Member
Member
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.
This is in support of #24400. The reason this enhancement is needed is that extensions like editorconfig-vscode call the
editor.action.trimTrailingWhitespacecommand during an auto-save event, and without knowing whether the command was triggered by an auto-save event the code can't know whether to trim trailing whitespace at the cursor (causing the cursor to move) or not.This change will allow fixing editorconfig-vscode #47.