roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
4.18k stars 297 forks source link

Don't run empty commands (including comments) #6951

Open ageron opened 2 months ago

ageron commented 2 months ago

This PR makes sure the REPL ignores empty commands, including comment-only commands. This is useful if you want to give yourself some visual space by typing Enter several times. It's also useful if you want to write some comments for educational purposes.

Before

»                [I just typed Enter here]

Enter an expression to evaluate, or a definition (like x = 1) to use later.

  - ctrl-v + ctrl-j makes a newline
  - :q quits
  - :help shows this text again

» # You can do plenty of things in the Roc REPL,
… # including arithmetic:

Enter an expression to evaluate, or a definition (like x = 1) to use later.

  - ctrl-v + ctrl-j makes a newline
  - :q quits
  - :help shows this text again

» 2 * 3

6 : Num *
» 

After

»

» # You can do plenty of things in the Roc REPL,
… # including arithmetic:

» 2 * 3

6 : Num *

I also replaced line.trim() with line.trim_end(), because the spaces don't hurt, and sometimes you want to keep those spaces for visual purposes, for example:

»         ############
… 2 * 3   # AMAZING! #
…         ############

6 : Num *
ageron commented 2 months ago

I'm not sure why this PR is failing, it looks like the failure is due to some other change, unrelated to this PR. Wdyt?

github-actions[bot] commented 4 weeks ago

Thank you for your contribution! Sometimes PRs end up staying open for a long time without activity, which can make the list of open PRs get long and time-consuming to review. To keep things manageable for reviewers, this bot automatically closes PRs that haven’t had activity in 60 days. This PR hasn’t had activity in 30 days, so it will be automatically closed if there is no more activity in the next 30 days. Keep in mind that PRs marked Closed are not deleted, so no matter what, the PR will still be right here in the repo. You can always access it and reopen it anytime you like!