Skip to content

Commit 3c4aff4

Browse files
committed
non-selectable cell was selected inside CaretSelection
1 parent 46a0c17 commit 3c4aff4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class CaretSelection(val layoutable: LayoutableCell, val start: Int, val end: In
4747
if (previous != null) {
4848
if (event.modifiers.shift) {
4949
val commonAncestor = layoutable.cell.commonAncestor(previous.cell)
50-
editor.changeSelection(CellSelection(commonAncestor, true, this))
50+
val selectableAncestor = commonAncestor.ancestors(true).filter { it.isSelectable() }.firstOrNull()
51+
selectableAncestor?.let { editor.changeSelection(CellSelection(it, true, this)) }
5152
} else {
5253
editor.changeSelection(CaretSelection(previous, previous.cell.getMaxCaretPos()))
5354
}
@@ -68,7 +69,8 @@ class CaretSelection(val layoutable: LayoutableCell, val start: Int, val end: In
6869
if (next != null) {
6970
if (event.modifiers.shift) {
7071
val commonAncestor = layoutable.cell.commonAncestor(next.cell)
71-
editor.changeSelection(CellSelection(commonAncestor, false, this))
72+
val selectableAncestor = commonAncestor.ancestors(true).filter { it.isSelectable() }.firstOrNull()
73+
selectableAncestor?.let { editor.changeSelection(CellSelection(it, false, this)) }
7274
} else {
7375
editor.changeSelection(CaretSelection(next, 0))
7476
}

0 commit comments

Comments
 (0)