flow icon indicating copy to clipboard operation
flow copied to clipboard

[lsp] Weird issue with completion in v0.97.0

Open d4ncer opened this issue 7 years ago • 4 comments

Hello!

I'm having a strange issue when triggering a completion with v0.97.0 - it looks like the Flow LSP is sending back character offsets based on 1 instead of 0, as found here (thanks to @yyoncho for investigating this!). This results in broken code after triggering the completion (see the GIF below).

Environment

Flow version: v0.97.0 Client: Emacs + lsp-mode + company-lsp

Expected behavior

When triggering a completion, I expect the result code to be correct.

Actual behavior

flow lsp 0.97.0 breaks completion

On a very brief investigation into the PR that introduced this change, I think this behaviour could be caused by this line, but I could be wrong; my OCaml knowledge is non-existent.

Let me know if there's something I can configure on the LSP server to fix this behaviour. Thank you!

d4ncer avatar Apr 22 '19 04:04 d4ncer

I think you're right about that logic being the problem. Looking at the lsp spec, the textEdit range should denote the text to replace i.e. you've already typed part of the completion. So:

x.|

start.character = character // 2
end.character = character // 2


x.toEx|

start.character = character - 4 // 2
end.character = character // 6

kirbycool avatar Apr 24 '19 21:04 kirbycool

@vicapow did you observe similar behaviour in VSCode or any other editors while you were working on this functionality?

d4ncer avatar Apr 25 '19 05:04 d4ncer

Fixed in v0.101.0 (see 909e50ec472aa7a2c52678ba2ba94668b483368f)

Mayank1791989 avatar Jun 11 '19 17:06 Mayank1791989

Thanks for pointing that out @Mayank1791989! Closing this.

d4ncer avatar Jun 11 '19 18:06 d4ncer