imc-trading / svlangserver

MIT License
95 stars 13 forks source link

Go to Definition does not work when a label is fully selected. #10

Closed mlefebvre1 closed 2 years ago

mlefebvre1 commented 2 years ago

Hi, It seems there is an issue with the go to definition in vscode when a label is fully selected (either by selecting it manually or by double clicking it). If I partially select the label instead (single click on the label or select some characters of the label, but not all of them), then, the go to definition works perfectly.

Here is the output console when the label is fully selected :

[Trace - 9: 42: 19 a.m.
] Sending request 'textDocument/definition - (236)'.
Params: {
  "textDocument": {
    "uri": "file:///home/mlefebvre/Downloads/svlangserv/module1.sv"
  },
  "position": {
    "line": 7,
    "character": 9
  }
}

[Trace - 9: 42: 19 a.m.
] Received response 'textDocument/definition - (236)' in 1ms.
Result: []

When the label is partially selected :

[Trace - 9: 37: 02 a.m.
] Sending request 'textDocument/definition - (178)'.
Params: {
  "textDocument": {
    "uri": "file:///home/mlefebvre/Downloads/svlangserv/module1.sv"
  },
  "position": {
    "line": 7,
    "character": 3
  }
}

[Trace - 9: 37: 02 a.m.
] Received response 'textDocument/definition - (178)' in 2ms.
Result: [
  {
    "uri": "/home/mlefebvre/Downloads/svlangserv/module2.sv",
    "range": {
      "start": {
        "line": 0,
        "character": 7
      },
      "end": {
        "line": 0,
        "character": 14
      }
    }
  }
]

It seems that the response sent back by svlangserver is empty when the label is fully selected.

Setup :

svlangserver v0.3.4

code --version                                                                                                                                                                                                                                                                                                            
1.60.2
7f6ab5485bbc008386c4386d08766667e155244e
x64
kkanhere commented 2 years ago

Thanks for reporting this.

This is one of those case where different clients send position differently. In my coc.nvim client, the position is the position of the character under cursor, but in vscode it seems to be the position of character after the cursor.

I will fix this by looking for the word at the provided position as well as previous position. Hopefully that keeps everybody happy.

kkanhere commented 2 years ago

Fixed in release 0.3.5