Skip to content

Commit

Permalink
Fix for #16771. Now insertCursorAtEndOfEachLineSelected works with mu…
Browse files Browse the repository at this point in the history
…ltiple selections.
  • Loading branch information
Matt Downs authored and Matt Downs committed Dec 23, 2016
1 parent fd96ccb commit cabcd28
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/vs/editor/contrib/multicursor/common/multicursor.ts
Expand Up @@ -8,6 +8,7 @@ import * as nls from 'vs/nls';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { Handler, ICommonCodeEditor, EditorContextKeys, ISelection } from 'vs/editor/common/editorCommon';
import { editorAction, ServicesAccessor, EditorAction, HandlerEditorAction } from 'vs/editor/common/editorCommonExtensions';
import { Selection } from 'vs/editor/common/core/selection';

@editorAction
class InsertCursorAbove extends HandlerEditorAction {
Expand Down Expand Up @@ -67,10 +68,9 @@ class InsertCursorAtEndOfEachLineSelected extends EditorAction {
});
}

public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
let selection = editor.getSelection();
private getCursorsForSelection(selection: Selection, editor: ICommonCodeEditor): Array<ISelection> {
if (selection.isEmpty()) {
return;
return [];
}

let model = editor.getModel();
Expand All @@ -95,6 +95,16 @@ class InsertCursorAtEndOfEachLineSelected extends EditorAction {
});
}
}
editor.setSelections(newSelections);
return newSelections;
}

public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
let selections = editor.getSelections();
let newSelections = selections.map((selection) => this.getCursorsForSelection(selection, editor))
.reduce((prev, curr) => { return prev.concat(curr); });

if (newSelections.length > 0) {
editor.setSelections(newSelections);
}
}
}

0 comments on commit cabcd28

Please sign in to comment.