Skip to content

Commit

Permalink
Simple fix for index out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
pkukielka committed Feb 9, 2024
1 parent 6f75c53 commit ee4bfb7
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ class CodyAutocompleteManager {
val originalText = editor.document.getText(TextRange(offset - caretPositionInLine, offset))

val prefixStartPosition = maxOf(originalText.lastIndexOf("."), originalText.lastIndexOf(" "), 0)
if (!lookupString.isNullOrEmpty() &&
if (prefixStartPosition < originalText.length &&
!lookupString.isNullOrEmpty() &&
!lookupString.startsWith(
originalText.subSequence(prefixStartPosition + 1, originalText.length))) {
logger.debug("Skipping autocompletion for lookup element due to not matching prefix")
Expand Down

0 comments on commit ee4bfb7

Please sign in to comment.