@@ -34,11 +34,15 @@ data class CellSelection(val cell: Cell, val directionLeft: Boolean, val previou
34
34
if (event.modifiers.meta) {
35
35
cell.ancestors().firstOrNull { it.getProperty(CommonCellProperties .selectable) }
36
36
?.let { editor.changeSelection(CellSelection (it, directionLeft, this )) }
37
+ } else {
38
+ unwrapCaretSelection()?.selectNextPreviousLine(false )
37
39
}
38
40
}
39
41
KnownKeys .ArrowDown -> {
40
42
if (event.modifiers == Modifiers .META && previousSelection != null ) {
41
43
editor.changeSelection(previousSelection)
44
+ } else {
45
+ unwrapCaretSelection()?.selectNextPreviousLine(true )
42
46
}
43
47
}
44
48
KnownKeys .ArrowLeft , KnownKeys .ArrowRight -> {
@@ -51,8 +55,7 @@ data class CellSelection(val cell: Cell, val directionLeft: Boolean, val previou
51
55
previousSelection?.let { editor.changeSelection(it) }
52
56
}
53
57
} else {
54
- val caretSelection = generateSequence<Selection >(this ) { (it as ? CellSelection )?.previousSelection }
55
- .lastOrNull() as ? CaretSelection
58
+ val caretSelection = unwrapCaretSelection()
56
59
if (caretSelection != null ) {
57
60
editor.changeSelection(CaretSelection (caretSelection.layoutable, caretSelection.start))
58
61
} else {
@@ -73,6 +76,11 @@ data class CellSelection(val cell: Cell, val directionLeft: Boolean, val previou
73
76
return true
74
77
}
75
78
79
+ private fun unwrapCaretSelection (): CaretSelection ? {
80
+ return generateSequence<Selection >(this ) { (it as ? CellSelection )?.previousSelection }
81
+ .lastOrNull() as ? CaretSelection
82
+ }
83
+
76
84
fun getLayoutables (): List <Layoutable > {
77
85
val editor = getEditor() ? : return emptyList()
78
86
val rootText = editor.getRootCell().layout
0 commit comments