Skip to content

Missing newline when evaluate on last line #1213

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

Closed
t4ccer opened this issue Dec 18, 2020 · 6 comments · Fixed by #1223
Closed

Missing newline when evaluate on last line #1213

t4ccer opened this issue Dec 18, 2020 · 6 comments · Fixed by #1223
Labels
component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@t4ccer
Copy link

t4ccer commented Dec 18, 2020

Using Evaluate on

-- >>> take 5 [0..]

produces

-- >>> take 5 [0..]-- [0,1,2,3,4]
<here is newline>

instead of

-- >>> take 5 [0..]
-- [0,1,2,3,4]

when >>> take 5 [0..] is on the last line of file. I believe that appending newline character on beginning of Evaluate's output instead of at the and will solve the issue.

@jneira
Copy link
Member

jneira commented Jan 11, 2021

There were some pr's about newlines in the eval plugin, f.e.:

Maybe this is related with them?
//cc @expipiplus1

@expipiplus1
Copy link
Contributor

I can't reproduce this with haskell-language-server version: 0.7.1.0 (GHC: 8.10.3) I think there was some other more recent work done on the eval plugin.

@jneira
Copy link
Member

jneira commented Jan 11, 2021

@expipiplus1 many thanks for checking it
@t4ccer could you reproduce it with that version of hls (or the newer one 0.8.0)?

@t4ccer
Copy link
Author

t4ccer commented Jan 15, 2021

Hmm that's interesting, I can still reproduce it using haskell-language-server version: 0.8.0 (GHC: 8.10.1). I used this file as input.

@jneira jneira transferred this issue from haskell/vscode-haskell Jan 15, 2021
@jneira jneira added component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jan 15, 2021
@expipiplus1
Copy link
Contributor

@tittoassini is perhaps a better person to look at this.

@tittoassini
Copy link
Contributor

The problem is that the Eval plugin will instruct the client to add the result in the line after the test.

However, if the line does not exist, the client will attach it to the last line instead.

For File:
0: module TLastLine where
1:
2:-- >>> take 5 [1..]-- [1,2,3,4,5]

We say "put the result on line 3":

{"jsonrpc":"2.0","params":{"edit":{"changes":{"file:///Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata/TLastLine.hs":[{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"-- [1,2,3,4,5]\n"}]}}},"method":"workspace/applyEdit","id":14}

Clients says: "ok, there is no line 3 so it goes at the end of line 2!":

{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata/TLastLine.hs","version":20},"contentChanges":[{"range":{"start":{"line":2,"character":19},"end":{"line":2,"character":19}},"rangeLength":0,"text":"-- [1,2,3,4,5]\n"}]}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants