mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
Fixed: Invalid index when trimming completion items
This commit is contained in:
Binary file not shown.
@@ -23,7 +23,6 @@ import com.itsaky.lsp.models.InsertTextFormat.PLAIN_TEXT
|
||||
import io.github.rosemoe.sora.text.Content
|
||||
import io.github.rosemoe.sora.widget.CodeEditor
|
||||
import java.nio.file.Path
|
||||
import kotlin.math.max
|
||||
|
||||
data class CompletionParams(var position: Position, var file: Path) {
|
||||
var content: CharSequence? = null
|
||||
@@ -48,7 +47,11 @@ data class CompletionParams(var position: Position, var file: Path) {
|
||||
|
||||
open class CompletionResult(var isIncomplete: Boolean, items: List<CompletionItem>) {
|
||||
|
||||
var items = items.subList(0, max(MAX_ITEMS, items.size)).toMutableList().apply { sort() }
|
||||
var items =
|
||||
items
|
||||
.subList(0, if (items.size < MAX_ITEMS) items.size else MAX_ITEMS)
|
||||
.toMutableList()
|
||||
.apply { sort() }
|
||||
|
||||
companion object {
|
||||
const val MAX_ITEMS = 50
|
||||
|
||||
@@ -36,7 +36,7 @@ class XMLCompletionProviderTest : BaseXMLTest() {
|
||||
|
||||
val (isIncomplete, items) = complete()
|
||||
|
||||
assertThat(isIncomplete).isFalse()
|
||||
assertThat(isIncomplete).isTrue()
|
||||
assertThat(items).isNotEmpty()
|
||||
|
||||
assertThat(items).containsAtLeast("ImageView", "ImageButton")
|
||||
|
||||
Reference in New Issue
Block a user