Skip to content

Commit

Permalink
Check offset against document length while typing } at the end of t…
Browse files Browse the repository at this point in the history
…he document. Fixes #19.
  • Loading branch information
Krotki committed Jan 5, 2025
1 parent 447cf37 commit 46e2bab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/io/vlang/lang/completion/VlangTypedHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class VlangTypedHandler : TypedHandlerDelegate() {
}

val document = editor.document
val chars = document.charsSequence
val chars = document.immutableCharSequence
val offset = editor.caretModel.offset

if (offset > 10) {
Expand All @@ -45,7 +45,7 @@ class VlangTypedHandler : TypedHandlerDelegate() {
}
}

if (c == '}') {
if (c == '}' && offset < chars.length) {
val nextChar = chars.subSequence(offset, offset + 1).firstOrNull()
if (nextChar == '}') {
document.deleteString(offset, offset + 1)
Expand Down

0 comments on commit 46e2bab

Please sign in to comment.