Release-Candidate / vscode-scheme-repl

A Visual Studio Code extension for Chez Scheme, it uses the REPL for autocompletions and to evaluate expressions.
MIT License
13 stars 0 forks source link

Sometimes, "Send the whole current file to the REPL" sends only the initial lines of code after the REPL is closed. #5

Closed vagreargnatry closed 1 year ago

vagreargnatry commented 1 year ago

Thank you to the author for creating this fantastic software. It has helped me write Scheme code more comfortably. But I still have some questions below.

Describe the bug The content of the file is as follows. When using Send the whole current file to the REPL the code appearing in the REPL is missing the initial lines (the number of missing lines seems to be related to the number of characters in the preceding lines).

(define (fact n) (cond [(< n 1) "error"] [(= n 1) 1] [else (* n (fact (sub1 n)))]))

(define (fact-iter n)
  (define (iter cnt acc)
    (if (= cnt 1)
    acc
    (iter (sub1 cnt) (* cnt acc))))
  (cond
    [(< n 1) "error"]
    [else (iter n 1)]))

(define (counter state)
  (lambda (info)
    (cond
     [(eq? info 'add1) (set! state (add1 state))]
     [(eq? info 'sub1) (set! state (sub1 state))]
     [(eq? info 'get) state]
     [(eq? info 'reset) (set! state 0)]
     [else "error"])))

To Reproduce Steps to reproduce the behavior:

  1. Use Powershell 7.3.4 or GNU bash, version 5.2.15(1)-release (x86_64-pc-msys) or Powershell 5.1.22621.1778 as VS Code default terminal.
  2. Open the file.
  3. Use Send the whole current file to the REPL

Expected behavior The file content can be sent to the REPL all at once, ensuring that all the code is executed correctly.

Screenshots Powershell 7.3.4 powershell Git Bash git-bash Command Prompt (cmd) cmd

Logs

Chez Scheme REPL starting.
Registered all commands
Extension startup finished.
Sent to REPL using command chezScheme.sendSelectionToREPL
Sent to REPL using command chezScheme.sendSelectionToREPL
Sent to REPL using command chezScheme.sendSelectionToREPL

Environment (please complete the following information):

Additional context When using cmd (Command Prompt) as VS Code's default terminal, there is no such issue. This issue may not occur consistently, but it seems to be happening frequently in my case.

This issue will also make "Send selected s-expression to the REPL" unavailable. 4

Release-Candidate commented 1 year ago

Could it be that this is a timing issue, that the REPL took to long to start? VS Code does not give me a way to know if the REPL in the terminal I have started has finished it's startup before sending the file, as of now I'm just waiting 1s.

Please test if the same issue appears when first starting the REPL by clicking at the Chez Scheme REPL: Start REPL button on the upper right or executing the command Chez Scheme REPL: Start REPL and only after the REPL has been started sending the whole file to the REPL.

If it is, I could make the delay between the start of the terminal and REPL and sending data to it configurable.

Release-Candidate commented 1 year ago

A remark: exiting the REPL but leaving the REPL Window open does not work. Because VS Code does not let me know if the REPL is running or not, I can only control the existence of the terminal window named Chez Scheme REPL. If this window exists, I do not start the REPL but just send the Scheme source to the terminal.

So please always close the Chez Scheme REPL Terminal window after exiting the REPL.

vagreargnatry commented 1 year ago

Could it be that this is a timing issue, that the REPL took to long to start? VS Code does not give me a way to know if the REPL in the terminal I have started has finished it's startup before sending the file, as of now I'm just waiting 1s.

Please test if the same issue appears when first starting the REPL by clicking at the Chez Scheme REPL: Start REPL button on the upper right or executing the command Chez Scheme REPL: Start REPL and only after the REPL has been started sending the whole file to the REPL.

If it is, I could make the delay between the start of the terminal and REPL and sending data to it configurable.

When using this method, the issue will no longer occur.

Release-Candidate commented 1 year ago

Great, I'll make that delay between starting the terminal and sending the code to the REPL configurable.

Release-Candidate commented 1 year ago

The new version 0.4.0 has this configurable delay, chezScheme.replDelay.

Please try if increasing this delay solves your problem.

vagreargnatry commented 1 year ago

Thank you! Increasing this delay solves my problem.

Release-Candidate commented 1 year ago

Great to hear.

Thank you again very much for your help!