-
-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make repl ignore a blank string rather than evaluating it #2235
Conversation
b32c4e8
to
ba0c1ee
Compare
cider-repl.el
Outdated
(string-match-p "\\`[ \t\r\n]*\\'" input)) | ||
(cider--nrepl-pprint-request-plist (cider--pretty-print-width)))))) | ||
(let ((input (cider-repl--current-input))) | ||
(unless (string= input "") ; don't evaluate an empty string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string-empty-p
ba0c1ee
to
1ffc5ef
Compare
LGTM. This doesn't affect printing the next prompt, right? Just want to make sure we weren't doing the printing in an eval handler or something like this. |
cider-repl.el
Outdated
(string-match-p "\\`[ \t\r\n]*\\'" input)) | ||
(cider--nrepl-pprint-request-plist (cider--pretty-print-width)))))) | ||
(let ((input (cider-repl--current-input))) | ||
(unless (string-empty-p input) ; don't evaluate an empty string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I'm curious if this will work properly if you type a few spaces and then press Return in the REPL. Likely not, so probably we need a bit more robust check for no input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess string-blank-p
should do the trick.
1ffc5ef
to
9e28777
Compare
Ok, I adopted If the input string contains only whitespace (including newlines) then we clear the input without evaluating, print a fresh prompt, and we do NOT evaluate or add the blank input to the history. Otherwise, if the input is not blank it is evaluated as usual. |
9e28777
to
666f2f6
Compare
Nicely done! 👍 |
I think this change is a "usability" regression. The process might be killed or locked for whatever reason, but my returns go through as if nothing happened. I am so used to sending RETs as a control for hang in all emacs REPLs that I find this new behavior rather disturbing. What bug does this change fix more concretely? The referenced comment doesn't shed light on the nature of the bug. |
I considered this a bug because when you press Ret on an empty line technically you haven't entered anything, but you ended up evaluating an empty string. For me the only case in which you should eval an empty string should be typing |
That's an interesting argument that I didn't think of, though. I generally just type something to test this, so it never came to my mind that someone might be testing their REPL in this manner. |
Shouldn't this be taken care by nREPL automatically? To my mind the eval op should differentiate between
Never came to my mind that someone might be testing their REPL in this manner either :) |
As the subject says. The bug was identified and commented on in #1115 (comment)
I'll push some additional changes to this branch to finish up the checklist below.
Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):
make test
)make lint
) which is based onelisp-lint
and includescheckdoc
, check-declare, packaging metadata, indentation, and trailing whitespace checks.Thanks!
If you're just starting out to hack on CIDER you might find this section of its
manual extremely useful.