mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-19 03:21:36 -04:00
Merge from vscode 718331d6f3ebd1b571530ab499edb266ddd493d5
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user