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 12, 2024
1 parent 6f75c53 commit ac2e148
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,8 @@ class CodyAutocompleteManager {
val caretPositionInLine = offset - editor.document.getLineStartOffset(lineNumber)
val originalText = editor.document.getText(TextRange(offset - caretPositionInLine, offset))

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

0 comments on commit ac2e148

Please sign in to comment.