mirror of
https://github.com/Microsoft/vscode
synced 2024-09-19 10:40:41 +00:00
Remove optional argument, document reason for looking at args
This commit is contained in:
parent
6a133b2af2
commit
5d3dfe86cd
|
@ -17,7 +17,7 @@ export class TrimTrailingWhitespaceCommand implements editorCommon.ICommand {
|
|||
private selectionId: string;
|
||||
private cursors: Position[];
|
||||
|
||||
constructor(selection: Selection, cursors: Position[] = []) {
|
||||
constructor(selection: Selection, cursors: Position[]) {
|
||||
this.selection = selection;
|
||||
this.cursors = cursors;
|
||||
}
|
||||
|
|
|
@ -209,8 +209,11 @@ export class TrimTrailingWhitespaceAction extends EditorAction {
|
|||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor, args: any): void {
|
||||
|
||||
var cursors: Position[];
|
||||
let cursors: Position[] = [];
|
||||
if (args.reason === 'auto-save') {
|
||||
// See https://github.com/editorconfig/editorconfig-vscode/issues/47
|
||||
// It is very convenient for the editor config extension to invoke this action.
|
||||
// So, if we get a reason:'auto-save' passed in, let's preserve cursor positions.
|
||||
cursors = editor.getSelections().map(s => new Position(s.positionLineNumber, s.positionColumn));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import { withEditorModel } from 'vs/editor/test/common/editorTestUtils';
|
|||
|
||||
function assertTrimTrailingWhitespaceCommand(text: string[], expected: IIdentifiedSingleEditOperation[]): void {
|
||||
return withEditorModel(text, (model) => {
|
||||
var op = new TrimTrailingWhitespaceCommand(new Selection(1, 1, 1, 1));
|
||||
var op = new TrimTrailingWhitespaceCommand(new Selection(1, 1, 1, 1), []);
|
||||
var actual = getEditOperation(model, op);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue