提交 5d3dfe86 编写于 作者: A Alex Dima

Remove optional argument, document reason for looking at args

上级 6a133b2a
......@@ -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);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册