sourcegraph/javascript-typescript-langserver

Completions result is not adequate

danielnowakowski opened this issue · 7 comments

I'm using version 2.9.4 and I've noticed that completions feature does not work as expected.

Please look at the following code (file test2.js):

class TestClass {
    met1(arg1) {
        console.log(arg1);
    }
}

const myObj = new TestClass();
my

Cursor is placed just after 'my' at the end and I'm triggering completion feature. I'm expecting to have 'myObj' in the results and probably some other possibilities with 'my' somewhere in the names.

Initialize request:

Content-Length: 303

{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"rootUri":"file://PROJECT_PATH","capabilities":{"workspace":{"applyEdit":true},"textDocument":{"completion":{"completionItem":{"snippetSupport":true}},"synchronization":{"didSave":true}}}}}

Completion request:

Content-Length: 240

{"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{"textDocument":{"uri":"file://FILE_PATH/test2.js"},"position":{"line":7,"character":2}}}

Result is attached in file. Please notice, that uri is changed by me before publishing this issue, but it is proper.

output_file.txt

What client are you using? Could you post the full LSP log?
Could it be that you are running into #432?

I don't think that this issue is related to #432, as that issue describes problem with one character behind.

I'm implementing my own client.

I'm attaching full logs.

full_output_file.txt

Hm, yeah, that is indeed wrong. Here's the content from the didChange:

0 class TestClass {
1     met1(arg1) {
2         console.log(arg1);
3     }
4 }
5 
6 const myObj = new TestClass();
7 my
  012

And the requested position is 7:2.

I see that you have changed the file URIs (the ones in your log are actually invalid because they are not absolute), could you post the real ones? Maybe the file URIs don't align. And are there any logs from the language server?

File paths are always absolute. Unfortunately, I cannot paste the real ones.

I'm able to produce completion request for this file that works, so you could see that problem is not with paths.

I'm attaching server logs.

server_logs.txt

Sorry, don't know what causes this then.

Hey @felixfbecker, I'm seeing this too. I created a simple repro via this Python script.

The script starts up the language server, then sends

  1. Initialize command with pretty much everything enabled
  2. didOpen command for a simple file containing the text con
  3. Completion command

It prints out the completion result, which you can see is similarly crazy to that reported by @danielnowakowski -- I'm expecting completions like console but instead it seems to report everything it can think of.

@felixfbecker friendly ping, any chance you can take a look at this? It seems like a major bug.