Skip to content
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

guile.socket: Sending excess newlines hangs up client #181

Closed
taw10 opened this issue Feb 27, 2021 · 2 comments
Closed

guile.socket: Sending excess newlines hangs up client #181

taw10 opened this issue Feb 27, 2021 · 2 comments
Assignees
Labels
bug Something isn't working client-guile

Comments

@taw10
Copy link
Contributor

taw10 commented Feb 27, 2021

I found a small(ish) issue while putting the new Guile client through its paces. Steps to reproduce:

  • Open new file, connect client etc. Verify correct operation by sending some test forms.
  • Place the cursor on an empty line in the file, with another empty line below
  • Enter visual selection mode with v, press down/j to select just the newline character
  • Send visual selection to Conjure with <LocalLeader>E
  • Attempt to send the same test forms as in step 1.

Expected outcome: the new evaluations proceed exactly as before.
Actual outcome: no further Conjure output until client is disconnected and reconnected with <LocalLeader>cd followed by <LocalLeader>cc.

Complete log output is below, but I think what's happening is that Conjure is waiting for a new prompt in response to the newline, as you would expect to see if you were to press enter on an empty line in a REPL. However, the socket REPL behaves differently. Connecting to the socket (using nc -U ~/starlet/guile.socket), then pressing enter on an empty line, does not produce a new prompt. Entering any kind of expression (e.g. 1) results in a normal evaluation and a new prompt:

$ nc -U ~/starlet/guile.socket
GNU Guile 3.0.4.25-de5d1
Copyright (C) 1995-2020 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (+ 1 2)
$21 = 3
scheme@(guile-user)>                                       <----- press enter a few times








1
$22 = 1
scheme@(guile-user)> (+ 2 3)
$23 = 5
scheme@(guile-user)>

Sending a single newline is a somewhat contrived example of course, but I came across the problem while trying to evaluate bigger blocks of code - any trailing newline causes the problem. A simple fix would be to strip out any trailing newlines before sending anything to the REPL. This filtering could be specific to the Guile client, or more global. Hopefully other socket-based REPLs have better behaviour!

Complete Conjure log output with debug:

; Sponsored by @penryu ❤
",m (guile-user)\
"
; --------------------------------------------------------------------------------
; /home/taw/starlet/guile.socket (connected)
; debug: receive
"GNU Guile 3.0.4.25-de5d1\
Copyright (C) 1995-2020 Free Software Foundation, Inc.\
\
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.\
This program is free software, and you are welcome to redistribute it\
under certain conditions; type `,show c' for details.\
\
Enter `,help' for help.\
scheme@(guile-user)> scheme@(guile-user)> "
; debug: send
",m (guile-user)\
"
; debug: receive
"scheme@(guile-user)> "
; --------------------------------------------------------------------------------
; eval (root-form): (use-modules (srfi srfi-1))
; debug: send
"(use-modules (srfi srfi-1))"
; debug: receive
"scheme@(guile-user)> "
; Empty result
; --------------------------------------------------------------------------------
; eval (root-form): (display "Hello\n")
; debug: send
"(display \"Hello\\n\")"
; debug: receive
"Hello\
"
; debug: receive
"Hello\
scheme@(guile-user)> "
; Empty result
; --------------------------------------------------------------------------------
; eval (root-form): (+ 1 2)
; debug: send
"(+ 1 2)"
; debug: receive
"$18 = "
; debug: receive
"$18 = 3\
scheme@(guile-user)> "
3
; --------------------------------------------------------------------------------
; eval (selection): 
; debug: send
"\
"
; --------------------------------------------------------------------------------
; eval (root-form): (+ 1 2)
; --------------------------------------------------------------------------------
; eval (root-form): (display "Hello\n")
; --------------------------------------------------------------------------------
; eval (root-form): (+ 1 2)
@Olical
Copy link
Owner

Olical commented Feb 28, 2021

Thanks for spotting this! Should be fixed on develop, I'm trimming the code strings down before sending them now and then just not doing it if it's blank. So sending just whitespace won't do anything now.

Guile's REPL doesn't display a new prompt on whitespace + new line, unlike basically every other REPL I can think of 😅

@Olical Olical self-assigned this Feb 28, 2021
@taw10
Copy link
Contributor Author

taw10 commented Feb 28, 2021

Thanks, seems to be fixed 100%!
Yeah, the different REPL behaviour took me by surprise as well. It's even different within a single Guile process between the terminal REPL and the socket REPL. I'm not sure why, even after looking at the code - maybe it's not intentional.

@taw10 taw10 closed this as completed Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working client-guile
Projects
None yet
Development

No branches or pull requests

2 participants