From eb55841447a38b7e875720e0f283f5c4340cf91d Mon Sep 17 00:00:00 2001 From: Mikhail Pyltsin Date: Sat, 14 Jan 2023 21:25:00 +0100 Subject: [PATCH] [java-completion] IDEA-359174 first draft of command completion - fix out of bounds exception GitOrigin-RevId: 352000f5b9f31c7a04b82e0ff3d88f78305c3179 --- .../completion/commands/core/CommandCompletionService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/commands/core/CommandCompletionService.kt b/java/java-impl/src/com/intellij/codeInsight/completion/commands/core/CommandCompletionService.kt index 96c91aee92db..9336749bbd4c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/commands/core/CommandCompletionService.kt +++ b/java/java-impl/src/com/intellij/codeInsight/completion/commands/core/CommandCompletionService.kt @@ -150,7 +150,7 @@ class CommandCompletionService( val newList: MutableList = 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)