purescript-language-server icon indicating copy to clipboard operation
purescript-language-server copied to clipboard

Quickfix for missing import duplicates identifier in coc.nvim

Open triallax opened this issue 5 years ago • 8 comments

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 avatar Feb 18 '20 20:02 triallax

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

triallax avatar Feb 19 '20 14:02 triallax

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

nwolverson avatar Feb 20 '20 09:02 nwolverson

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.

triallax avatar Feb 20 '20 13:02 triallax

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 avatar Jul 23 '20 12:07 nwolverson

Hopefully fixed in 39410035f7a29ed2d9daa7a0067c5ae6f63de1e8

nwolverson avatar Jul 24 '20 07:07 nwolverson

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.

triallax avatar Aug 06 '20 18:08 triallax

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.

nwolverson avatar Aug 06 '20 18:08 nwolverson

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

triallax avatar Aug 06 '20 18:08 triallax