@@ -59,22 +59,22 @@ fun completions(file: CompiledFile, cursor: Int, index: SymbolIndex, config: Com
59
59
val partial = findPartialIdentifier(file, cursor)
60
60
LOG .debug(" Looking for completions that match '{}'" , partial)
61
61
62
- var isIncomplete = false
63
62
// TODO: Filter non-imported (i.e. the elementCompletions already found) and auto-import these when selected by the user
64
- val items = (elementCompletionItems(file, cursor, config, partial) + indexCompletionItems(index, partial))
65
- .ifEmpty { keywordCompletionItems(partial).also { isIncomplete = true } }
63
+ val elementItems = elementCompletionItems(file, cursor, config, partial)
64
+ val elementItemList = elementItems.take(MAX_COMPLETION_ITEMS ).toList()
65
+ val items = (elementItemList.asSequence() + indexCompletionItems(index, partial)).ifEmpty { keywordCompletionItems(partial) }
66
66
val itemList = items
67
67
.take(MAX_COMPLETION_ITEMS )
68
68
.toList()
69
69
.onEachIndexed { i, item -> item.sortText = i.toString().padStart(2 , ' 0' ) }
70
- isIncomplete = isIncomplete || ( itemList.size == MAX_COMPLETION_ITEMS )
70
+ val isIncomplete = itemList.size >= MAX_COMPLETION_ITEMS || elementItemList.isEmpty( )
71
71
72
72
return CompletionList (isIncomplete, itemList)
73
73
}
74
74
75
75
/* * Finds completions in the symbol index. */
76
76
private fun indexCompletionItems (index : SymbolIndex , partial : String ): Sequence <CompletionItem > = index
77
- .query(partial)
77
+ .query(partial, limit = MAX_COMPLETION_ITEMS )
78
78
.map { CompletionItem ().apply {
79
79
label = it.fqName.shortName().toString()
80
80
kind = when (it.kind) {
0 commit comments