Skip to content

Commit 48f6c8e

Browse files
committed
allow to trigger code completion for a CellSelection
1 parent abf9678 commit 48f6c8e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,32 @@ data class CellSelection(val cell: Cell, val directionLeft: Boolean, val previou
7070
}
7171
}
7272
}
73-
else -> {}
73+
else -> {
74+
val typedText = event.typedText
75+
if (!typedText.isNullOrEmpty()) {
76+
val anchor = getLayoutables().filterIsInstance<LayoutableCell>().firstOrNull()
77+
if (anchor != null) {
78+
val actionProviders = cell.getSubstituteActions().toList()
79+
if (typedText == " " && event.modifiers == Modifiers.CTRL) {
80+
editor.showCodeCompletionMenu(
81+
anchor = anchor,
82+
position = CompletionPosition.CENTER,
83+
entries = actionProviders,
84+
pattern = "",
85+
caretPosition = 0
86+
)
87+
} else {
88+
editor.showCodeCompletionMenu(
89+
anchor = anchor,
90+
position = CompletionPosition.CENTER,
91+
entries = actionProviders,
92+
pattern = typedText,
93+
caretPosition = typedText.length
94+
)
95+
}
96+
}
97+
}
98+
}
7499
}
75100

76101
return true

0 commit comments

Comments
 (0)