Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
In REPL, ENTER means SUBMIT when:
- cursor is at end (discarding whitespaces) - and, input line is complete
  • Loading branch information
allanrenucci committed Jun 29, 2018
commit de2a214381a8e10c79359767fbca1bd30baf033e
10 changes: 6 additions & 4 deletions compiler/src/dotty/tools/repl/JLineTerminal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ final class JLineTerminal extends java.io.Closeable {

context match {
case ParseContext.ACCEPT_LINE =>
val lastLineOffset = line.lastIndexOfSlice(System.lineSeparator)
if (cursor <= lastLineOffset || ParseResult.isIncomplete(line)) incomplete()
// ENTER means SUBMIT when
// - cursor is at end (discarding whitespaces)
// - and, input line is complete
val cursorIsAtEnd = line.indexWhere(!_.isWhitespace, from = cursor) >= 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be called cursorNotAtEnd no? In any case, it's a bit confusing that the comment above describes the conditions for submitting, but the code checks the conditions for not submitting, either the code logic or the comment should be changed.

if (cursorIsAtEnd || ParseResult.isIncomplete(line)) incomplete()
else parsedLine("", 0)
// using dummy values,
// resulting parsed line is probably unused
// using dummy values, resulting parsed line is probably unused

case ParseContext.COMPLETE =>
// Parse to find completions (typically after a Tab).
Expand Down