[java-completion] IDEA-359174 first draft of command completion

- fix out of bounds exception

GitOrigin-RevId: 352000f5b9f31c7a04b82e0ff3d88f78305c3179
This commit is contained in:
Mikhail Pyltsin
2024-12-10 11:51:59 +00:00
committed by intellij-monorepo-bot
parent fc963eee94
commit eb55841447
@@ -150,7 +150,7 @@ class CommandCompletionService(
val newList: MutableList<PreviousActionInfoContainer> = if (index != 0) {
val previousBeforeDot = data?.firstOrNull()
val last = data?.firstOrNull()
if (previousBeforeDot != null && last != null) {
if (previousBeforeDot != null && last != null && offset - index > 0) {
val newString = editor.document.immutableCharSequence.substring(0, offset - index) + editor.document.immutableCharSequence.substring(offset)
if (newString.hashCode() == previousBeforeDot.hashcode) {
mutableListOf(previousBeforeDot)