Skip to content

Commit 5c3bdd5

Browse files
committed
Take cursor position into account when inserting a new line
1 parent 4cc5c83 commit 5c3bdd5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/src/dotty/tools/repl/JLineTerminal.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ final class JLineTerminal {
8787

8888
context match {
8989
case ParseContext.ACCEPT_LINE =>
90-
// TODO: take into account cursor position
91-
if (ParseResult.isIncomplete(line)) incomplete()
90+
val lastLineOffset = line.lastIndexOfSlice(System.lineSeparator)
91+
if (cursor <= lastLineOffset || ParseResult.isIncomplete(line)) incomplete()
9292
else parsedLine("", 0)
9393
// using dummy values,
9494
// resulting parsed line is probably unused

0 commit comments

Comments
 (0)