Skip to content

Commit 2db74a8

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

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ final class JLineTerminal {
8888
context match {
8989
case ParseContext.ACCEPT_LINE =>
9090
// TODO: take into account cursor position
91-
if (ParseResult.isIncomplete(line)) incomplete()
91+
val lastLineOffset = line.lastIndexOfSlice(System.lineSeparator)
92+
if (cursor <= lastLineOffset || ParseResult.isIncomplete(line)) incomplete()
9293
else parsedLine("", 0)
9394
// using dummy values,
9495
// resulting parsed line is probably unused

0 commit comments

Comments
 (0)