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

When using CRLF as line endings, it seems that Ctrl+Enter only executes the code on the last line. #3

Closed vagreargnatry closed 1 year ago

vagreargnatry commented 1 year ago

Describe the bug When I press Ctrl+Enter, some errors occur, as if the code hasn't been fully sent to the REPL. I personally feel that it might be related to whether the code is on the same line or not. The function named 'fact' here generates an error when it's not on the same line. However, when its code is on the same line, there is no error. The function named 'fact-iter' also exhibits the same behavior, where it generates an error when it's not on the same line. However, when its code is on the same line, there is no error.

When using LF (Line Feed) as line endings, there doesn't seem to be this issue, and Ctrl+Enter executes all the lines of code properly.

(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)]))

To Reproduce When using CRLF (Carriage Return Line Feed) as line endings.

Logs When using CRLF:

Chez Scheme REPL starting.
Registered all commands
Extension startup finished.
Sent 
     [else "error"]))) to REPL using command chezScheme.evalLastSexp

When using LF:

Chez Scheme REPL starting.
Registered all commands
Extension startup finished.
Sent (define (fact n) (cond [(< n 1) "error"] [(= n 1) 1] [else (* n (fact (sub1 n)))])) to REPL using command chezScheme.evalLastSexp
Sent (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)])) to REPL using command chezScheme.evalLastSexp

Environment (please complete the following information):

Release-Candidate commented 1 year ago

Thank you again for your help.

I can reproduce the problem, I'm going to add the missing \rs. Should not take too long, I hope.

As a temporary workaround you could also use **Send selected s-expression to the REPL" , which does work with \r\n line breaks.

Release-Candidate commented 1 year ago

The new version 0.3.0 works for me now. I've also checked for other potential \r\n issues, I hope I've fixed them all. Please check if the new version is working for you.

Thanks again for your help on Windows, much appreciated.

vagreargnatry commented 1 year ago

Thank you! The new version is working for me.

Release-Candidate commented 1 year ago

Great to hear! Thanks again for your help.