提交 71581538 编写于 作者: A Alex Dima

Fixes #38117

上级 deb2f763
......@@ -183,41 +183,39 @@ export class CursorCollection {
interface SortedCursor {
index: number;
selection: Selection;
viewSelection: Selection;
}
let sortedCursors: SortedCursor[] = [];
for (let i = 0, len = cursors.length; i < len; i++) {
sortedCursors.push({
index: i,
selection: cursors[i].modelState.selection,
viewSelection: cursors[i].viewState.selection
});
}
sortedCursors.sort((a, b) => {
if (a.viewSelection.startLineNumber === b.viewSelection.startLineNumber) {
return a.viewSelection.startColumn - b.viewSelection.startColumn;
if (a.selection.startLineNumber === b.selection.startLineNumber) {
return a.selection.startColumn - b.selection.startColumn;
}
return a.viewSelection.startLineNumber - b.viewSelection.startLineNumber;
return a.selection.startLineNumber - b.selection.startLineNumber;
});
for (let sortedCursorIndex = 0; sortedCursorIndex < sortedCursors.length - 1; sortedCursorIndex++) {
const current = sortedCursors[sortedCursorIndex];
const next = sortedCursors[sortedCursorIndex + 1];
const currentViewSelection = current.viewSelection;
const nextViewSelection = next.viewSelection;
const currentSelection = current.selection;
const nextSelection = next.selection;
if (!this.context.config.multiCursorMergeOverlapping) {
continue;
}
let shouldMergeCursors: boolean;
if (nextViewSelection.isEmpty() || currentViewSelection.isEmpty()) {
if (nextSelection.isEmpty() || currentSelection.isEmpty()) {
// Merge touching cursors if one of them is collapsed
shouldMergeCursors = nextViewSelection.getStartPosition().isBeforeOrEqual(currentViewSelection.getEndPosition());
shouldMergeCursors = nextSelection.getStartPosition().isBeforeOrEqual(currentSelection.getEndPosition());
} else {
// Merge only overlapping cursors (i.e. allow touching ranges)
shouldMergeCursors = nextViewSelection.getStartPosition().isBefore(currentViewSelection.getEndPosition());
shouldMergeCursors = nextSelection.getStartPosition().isBefore(currentSelection.getEndPosition());
}
if (shouldMergeCursors) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册