Merge from vscode 718331d6f3ebd1b571530ab499edb266ddd493d5

This commit is contained in:
ADS Merger
2020-02-08 04:50:58 +00:00
parent 8c61538a27
commit 2af13c18d2
752 changed files with 16458 additions and 10063 deletions

View File

@@ -37,12 +37,36 @@ abstract class AbstractCopyLinesAction extends EditorAction {
}
public run(_accessor: ServicesAccessor, editor: ICodeEditor): void {
if (!editor.hasModel()) {
return;
}
const selections = editor.getSelections().map((selection, index) => ({ selection, index, ignore: false }));
selections.sort((a, b) => Range.compareRangesUsingStarts(a.selection, b.selection));
// Remove selections that would result in copying the same line
let prev = selections[0];
for (let i = 1; i < selections.length; i++) {
const curr = selections[i];
if (prev.selection.endLineNumber === curr.selection.startLineNumber) {
// these two selections would copy the same line
if (prev.index < curr.index) {
// prev wins
curr.ignore = true;
} else {
// curr wins
prev.ignore = true;
prev = curr;
}
}
}
const commands: ICommand[] = [];
const selections = editor.getSelections() || [];
for (const selection of selections) {
commands.push(new CopyLinesCommand(selection, this.down));
if (selection.ignore) {
continue;
}
commands.push(new CopyLinesCommand(selection.selection, this.down));
}
editor.pushUndoStop();