Skip to content

Commit 57c9255

Browse files
committed
shift+left/right at the end of a text cell expands the selection to the parent cell
1 parent ee6c65e commit 57c9255

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

editor-runtime/src/commonMain/kotlin/org/modelix/editor/CaretSelection.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ class CaretSelection(val layoutable: LayoutableCell, val start: Int, val end: In
4545
.filterIsInstance<LayoutableCell>()
4646
.find { it.cell.getSelectableText() != null }
4747
if (previous != null) {
48-
editor.changeSelection(CaretSelection(previous, previous.cell.getMaxCaretPos()))
48+
if (event.modifiers.shift) {
49+
val commonAncestor = layoutable.cell.commonAncestor(previous.cell)
50+
editor.changeSelection(CellSelection(commonAncestor, this))
51+
} else {
52+
editor.changeSelection(CaretSelection(previous, previous.cell.getMaxCaretPos()))
53+
}
4954
}
5055
}
5156
}
@@ -61,7 +66,12 @@ class CaretSelection(val layoutable: LayoutableCell, val start: Int, val end: In
6166
.filterIsInstance<LayoutableCell>()
6267
.find { it.cell.getSelectableText() != null }
6368
if (next != null) {
64-
editor.changeSelection(CaretSelection(next, 0))
69+
if (event.modifiers.shift) {
70+
val commonAncestor = layoutable.cell.commonAncestor(next.cell)
71+
editor.changeSelection(CellSelection(commonAncestor, this))
72+
} else {
73+
editor.changeSelection(CaretSelection(next, 0))
74+
}
6575
}
6676
}
6777
}

0 commit comments

Comments
 (0)