tigersoldier / company-lsp

Company completion backend for lsp-mode
GNU General Public License v3.0
251 stars 26 forks source link

[flow] Weird issue with completion post v0.97.0 #107

Closed d4ncer closed 5 years ago

d4ncer commented 5 years ago

I upgraded to Flow 0.97.0, which contains support for snippets in completion in their LSP (see this PR) and have run into some weird issues where triggering the completion is deleting a single required char.

You can see it in action in the example below, one case where I run the completion directly after typing in ., and the other after narrowing it down a bit. In the first case, it deletes the . before adding in the completion, and in the second case, deletes the h and keeps the initial c instead of replacing all of it.

flow lsp 0.97.0 breaks completion

If this isn't the right place to handle this issue, let me know if I should post this issue somewhere else.

Thank you!

yyoncho commented 5 years ago

It seems like the flow language server send the character offset 1 based instead of 0 based.

Here it is the completion of "" in both jdtls and flow.

>>> jdtls
    "textEdit": {
      "range": {
        "start": {
          "line": 13,
          "character": 3
        },
        "end": {
          "line": 13,
          "character": 5
        }
      },
      "newText": "charAt(${1:index})"
    }

>> flow
    "textEdit": {
      "range": {
        "start": {
          "line": 1,
          "character": 2
        },
        "end": {
          "line": 1,
          "character": 4
        }
      },
      "newText": "charAt(${1:pos})"
    }

So I assume it is either flow ls bug or there is some setting that should be passed to the server to make it work properly.

d4ncer commented 5 years ago

Thanks for doing the heavy lifting @yyoncho! I'll open an issue with Flow and see what the best course of action is. Will close this out.