@@ -69,7 +69,6 @@ class PromptTextField(
69
69
private var currentPopup: JBPopup ? = null
70
70
private var currentParentGroup: LookupGroupItem ? = null
71
71
private var currentItems: List <LookupItem > = emptyList()
72
- private var allAvailableItems: List <LookupItem > = emptyList()
73
72
74
73
init {
75
74
isOneLineMode = false
@@ -111,21 +110,6 @@ class PromptTextField(
111
110
withContext(Dispatchers .EDT ) {
112
111
editor?.let { showPopupLookup(it, lookupItems) }
113
112
}
114
-
115
- allGroupItemsJob?.cancel()
116
- allGroupItemsJob = coroutineScope.launch {
117
- val allItems = mutableListOf<LookupItem >()
118
- lookupItems.forEach { group ->
119
- if (group is LookupGroupItem ) {
120
- runCatchingCancellable {
121
- allItems.addAll(group.getLookupItems())
122
- }
123
- } else {
124
- allItems.add(group)
125
- }
126
- }
127
- allAvailableItems = allItems
128
- }
129
113
}
130
114
131
115
private fun showPopupLookup (editor : Editor , items : List <LookupItem >) {
@@ -210,6 +194,16 @@ class PromptTextField(
210
194
e.consume()
211
195
}
212
196
197
+ KeyEvent .VK_DELETE , KeyEvent .VK_BACK_SPACE -> {
198
+ if (parentGroup != null ) {
199
+ showSuggestionsJob?.cancel()
200
+ showSuggestionsJob = coroutineScope.launch {
201
+ showGroupLookup()
202
+ }
203
+ e.consume()
204
+ }
205
+ }
206
+
213
207
else -> {
214
208
if (e.keyChar.isLetterOrDigit() || e.keyChar.isWhitespace()) {
215
209
searchField.textEditor.isEditable = true
@@ -240,6 +234,16 @@ class PromptTextField(
240
234
searchField.apply {
241
235
textEditor.isEditable = false
242
236
237
+ textEditor.addMouseListener(object : MouseAdapter () {
238
+ override fun mouseClicked (e : MouseEvent ) {
239
+ textEditor.isEditable = true
240
+ textEditor.requestFocusInWindow()
241
+ val text = textEditor.text
242
+ textEditor.caretPosition = text.length
243
+ textEditor.caret.isVisible = true
244
+ }
245
+ })
246
+
243
247
textEditor.addKeyListener(object : KeyAdapter () {
244
248
override fun keyPressed (e : KeyEvent ) {
245
249
when (e.keyCode) {
@@ -459,13 +463,6 @@ class PromptTextField(
459
463
}
460
464
}
461
465
462
- private fun handleSuggestionSelection (editor : Editor , item : LookupItem ) {
463
- if (item !is LookupActionItem ) return
464
-
465
- replaceAtSymbol(editor, item)
466
- onLookupAdded(item)
467
- }
468
-
469
466
private fun replaceAtSymbol (editor : Editor , lookupItem : LookupItem ) {
470
467
val offset = editor.caretModel.offset
471
468
val start = findAtSymbolPosition(editor)
@@ -509,7 +506,6 @@ class PromptTextField(
509
506
override fun dispose () {
510
507
searchJob?.cancel()
511
508
showSuggestionsJob?.cancel()
512
- allGroupItemsJob?.cancel()
513
509
currentPopup?.cancel()
514
510
}
515
511
0 commit comments