nwolverson / purescript-language-server

MIT License
184 stars 41 forks source link

Quickfix for missing import duplicates identifier in coc.nvim #66

Open triallax opened 4 years ago

triallax commented 4 years ago

I don't know if the issue stems from purescript-language-server or from coc.nvim. If the issue is indeed from coc.nvim, please tell me and then I'll create an issue there.

Here's a video demonstrating the issue.

(Sorry for bad quality, for some reason imgur trims down the video's quality)

triallax commented 4 years ago

I'm quite tired right now, but after I get enough rest I'll investigate this issue more and then comment what I discover.

nwolverson commented 4 years ago

I'll take a look at what happens for similar in vscode, if that shows the same issue then the answer is clear. We should be able to find out what messages are sent to/from the LSP and find out what's at fault in that way

triallax commented 4 years ago

Here's a log file that shows the communication between coc.nvim and purescript-language-server. The file is really large and hard to read, so I recommend putting the log file in this website.

nwolverson commented 4 years ago

Looking at that log, we supply a single edit which seems to have 2 things going on:

{
  "edit": {
    "documentChanges": [
      {
        "textDocument": {
          "uri": "file:///Users/mhmdanas/Desktop/projecteuler-solutions/Some.purs",
          "version": 98
        },
        "edits": [
          {
            "range": {
              "start": {
                "line": 9,
                "character": 55
              },
              "end": {
                "line": 9,
                "character": 44
              }
            },
            "newText": "shouldEqual"
          }
        ]
      }
    ],
    "changes": {
      "file:///Users/mhmdanas/Desktop/projecteuler-solutions/Some.purs": [
        {
          "range": {
            "start": {
              "line": 9,
              "character": 55
            },
            "end": {
              "line": 9,
              "character": 44
            }
          },
          "newText": "shouldEqual"
        }
      ]
    }
  }
}

Firstly, the range start/end seem to be reversed, which may be why the text is not replaced but appended. Secondly, the edit is supplied in the "old" and "new" forms. I was of the belief that documentChanges would take precedence over changes, but I think the spec is a bit unclear - we should only provide 1, but documentChanges "are preferred":

The edit should either provide changes or documentChanges. If the client can handle versioned document edits and if documentChanges are present, the latter are preferred over changes

nwolverson commented 4 years ago

Hopefully fixed in 39410035f7a29ed2d9daa7a0067c5ae6f63de1e8

triallax commented 4 years ago

I tried to check if this bug was fixed, but even before I updated to 0.13.6 from 0.12.9, quickfix didn't work anymore. Same in 0.13.6. I get this text at the bottom in red:

[coc.nvim] No quickfix action available

I'll try to check later, as it seems that it's a problem from my side.

nwolverson commented 4 years ago

Quickfix was borken in vscode for a long time, not sure what the status is post-update - I assume I fixed it... but that may have broken others.

triallax commented 4 years ago

I tested this in coc.nvim. I might install VSCode to check if it works there or not.