joaotavora / eglot

A client for Language Server Protocol servers
GNU General Public License v3.0
2.25k stars 200 forks source link

eglot jdt.ls completion add extra text #1349

Closed zsxh closed 8 months ago

zsxh commented 8 months ago
emacs master, emacs-repository-version: eac3f2a80778b3904c55ae7b65ff862a79eebf2a
jdt-language-server version: 1.31.0
jdk version: adoptopenjdk-21.0.1+12.0.LTS

file /tmp/demo/SingleFile.java

public class SingleFile {
  public static void main(String[] args) {

  }
}
  1. Ensure the java jdt.ls LSP server is installed and available in path
  2. Invoke Emacs master with Eglot master emacs -Q -f package-initialize /tmp/demo/SingleFile.java -f global-company-mode -f eglot
  3. line 3 type Array, select Arrays RET
  4. actual result
    
    import java.util.Arrays;

public class SingleFile { public static void main(String[] args) { Arraysray } }

expected result
``` java
import java.util.Arrays;

public class SingleFile {
  public static void main(String[] args) {
      Arrays
  }
}

eglot-jdtls.log

vdcow commented 8 months ago

I believe, it is not jdt.ls specific. Have the same issue with clangd. Also found relevant discussion in corfu

https://github.com/minad/corfu/discussions/400

joaotavora commented 8 months ago

Ok. Then please make a recipe for clangd that I can follow EXACTLY like @zsxh did. I can certainly follow that and come to a conclusion (@zsxh 's much harder to follow because it needs Java, which I don't want to be install)

vdcow commented 8 months ago

@joaotavora

Versions:

Emacs 29.1
eglot 1.16
company 20240107

Test file:

#include <vector>

int main(int argc, char *argv[])
{
    std::vector<int> v;
    v.push_back(5);
    return 0;
}

Steps:

  1. Open the file
    emacs -Q -f package-initialize main.cc -f global-company-mode -f eglot
  2. Type "v.p" in the line before "return 0" image
  3. Press Enter
  4. Check that there is extra "p" from entered "v.p" image
joaotavora commented 8 months ago

Thanks. Confirmed. Doesn't always happen though, have to debug.

joaotavora commented 8 months ago

Should be fixed in the latest master Emacs and also in the upcoming Eglot 1.17, which should be in GNU ELPA tomorrow

vdcow commented 8 months ago

That was fast! Thank you @joaotavora !