prabirshrestha / vim-lsp

async language server protocol plugin for vim and neovim
MIT License
3.13k stars 305 forks source link

textEdit applied at wrong position #1478

Closed dotdash closed 1 year ago

dotdash commented 1 year ago

Using vim-lsp with vim-ddc and intelephense, I'm working on a PHP file with a line like this:

    $node = [$r

triggering a completion at this point suggests $root as the completion, acccepting it results in this line though:

    $node = [$$root

This seems to be caused by vim-lsp, as according to the log file the language server sent the correct textEdit starting at character 14, but vim-lsp decided to apply it at character 15 instead:

Di 13 Jun 2023 09:18:23 CEST:[
  "<---",1,"intelephense",{
    "response":{
      "id":151,
      "jsonrpc":"2.0","result":{
        "isIncomplete":false,
        "items":[
          {
            "label":"$root",
            "data":"6029541403263124",
            "textEdit":{
              "range":{
                "end":{
                  "character":17,
                  "line":9
                },
                "start":{
                  "character":14,
                  "line":9
                }
              },
              "newText":"$root"
            },
            "sortText":"$root",
            "kind":6,
            "detail":"mixed"
          }
        ]
      }
    },
    "request":{
      "id":151,
      "jsonrpc":"2.0",
      "method":"textDocument/completion",
      "params":{
        "textDocument":{
          "uri":"file:///redacted.php"
        },
        "position":{
          "character":17,
          "line":9
        }
      }
    }
  }
]

Di 13 Jun 2023 09:18:25 CEST: [
  "--->", 1, "intelephense", {
    "method":"textDocument/didChange",
    "params":{
      "contentChanges":[
        {
          "range":{
            "end":{
              "character":17,
              "line":9
            },
            "start":{
              "character":15,
              "line":9
            }
          },
          "text":"$root",
          "rangeLength":2
        }
      ],
      "textDocument":{
        "uri":"file:///redacted.php",
        "version":83
      }
    }
  }
]
dotdash commented 1 year ago

Sorry for the noise, this seems to be a problem with the vim-lsp module for ddc, which does not respect the start column provided by vim-lsp.