Skip to content

Commit

Permalink
bugfix: handle EOF in java completions
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Sep 20, 2023
1 parent f8ddd02 commit f5aa2eb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class JavaCompletionProvider(
lazy val identifier = extractIdentifier.toLowerCase
def completions(): CompletionList = {
val nextIsWhitespace =
params.text().charAt(params.offset()).isWhitespace
if (params.offset() < params.text().length())
params.text().charAt(params.offset()).isWhitespace
else false
val textWithSemicolon =
if (nextIsWhitespace)
params.text().substring(0, params.offset()) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class JavaToplevelMtags(val input: Input.VirtualFile) extends MtagsIndexer {
@tailrec
def kwOrIdent(start: Int, builder: StringBuilder): Token = {
val ch = reader.ch
if (Character.isJavaIdentifierPart(ch)) {
if (ch != SU && Character.isJavaIdentifierPart(ch)) {
reader.nextChar()
kwOrIdent(start, builder.append(ch))
} else if (builder.isEmpty) {
Expand Down
9 changes: 9 additions & 0 deletions tests/javapc/src/test/scala/pc/CompletionKeywordSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ class CompletionKeywordSuite extends BaseJavaCompletionSuite {
|""".stripMargin,
)

check(
"end of file",
"""
|pac@@""".stripMargin,
"""
|package
|""".stripMargin,
)

check(
"extends",
"""
Expand Down

0 comments on commit f5aa2eb

Please sign in to comment.