question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent filterText and textEdit are returned, violating the LSP spec

See original GitHub issue

Completing the following line:

        java.util.concurrent.atomic.

In this case the server returns:

[Trace - 08:10:19 AM] Received response 'textDocument/completion - (166)' in 37ms.
Result: {
  "items": [
    {
      "data": {
        "uri": "file:///home/kyoncho/Sources/lsp/dap-mode/features/fixtures/test-project/src/main/java/temp/App.java",
        "rid": "20",
        "pid": "0",
        "decl_signature": "Ljava.util.concurrent.atomic.AtomicBoolean;"
      },
      "textEdit": {
        "newText": "java.util.concurrent.atomic.AtomicBoolean",
        "range": {
          "end": {
            "character": 36,
            "line": 9
          },
          "start": {
            "character": 8,
            "line": 9
          }
        }
      },
      "insertTextFormat": 2,
      "insertText": "AtomicBoolean",
      "filterText": "AtomicBoolean",
      "sortText": "999999180",
      "detail": "java.util.concurrent.atomic.AtomicBoolean",
      "kind": 7,
      "label": "AtomicBoolean - java.util.concurrent.atomic"
    },
....

As per spec the clients are supposed to use the textEdit range to find out where the completion has started and then filter it against filterText. In this case, the completion of prefix is calculated as java.util.concurrent.atomic. while the filter text is AtomicBoolean.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
yyonchocommented, Feb 17, 2020

I guess it’s because in Case 2, instead of an empty string, vscode filtered the items using the full line java.util.concurrent.. I think @jrieken might know what’s happening behind. Is that a bug of vscode?

That is because JDT LS returns incorrect text range in Case 2 - the clients use Completion.textEdit.range to calculate what to filter against.

1reaction
jriekencommented, Feb 17, 2020

the clients use Completion.textEdit.range to calculate what to filter against.

That’s correct - the range serves as the range that is replaced upon insertion and selects the prefix that’s used for filtering and sorting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Language Server Protocol Specification - 3.14
A request that got canceled still needs to return from the server and send a response back. It can not be left open...
Read more >
The Liskov Substitution Principle Explained - Reflectoring
If substituting a superclass object with a subclass object changes the program behavior in unexpected ways, the LSP is violated.
Read more >
Diff - vscode-go - Google Git
+ +If you see an "inconsistent vendoring" error, please report it at ... + break; + default: + // Go function can return...
Read more >
NorthStar Planner Desktop Application User Guide
A (non-spec) file: Launches the Text Editor where you may edit the file. ... string in the Filter text box and pressing <Enter>...
Read more >
Bug List - Bugs - Eclipse
HEAD) returns null even if the repository has a HEAD, 2021-12-27 ... Trailing colon in filter text dropped when state is loaded from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found