emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.79k stars 889 forks source link

typescript [ts-ls/eslint] expands incorrectly yasnippets snippets with mirrors #3158

Open viglioni opened 3 years ago

viglioni commented 3 years ago

Thank you for the bug report

Bug description

When both eslint and ts-ls are on, snippets that have mirrors expands incorrectly.

Note: if only either one of these backends is on, this bug does not occur.

https://user-images.githubusercontent.com/11412209/137915154-648efc8c-9b43-4ff3-ad57-5c8d819e5510.mp4

Steps to reproduce

  1. Add yasnippet-snippets to dependencies:
    (pkg-list '(lsp-mode lsp-ui yasnippet yasnippet-snippets lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright
                            ;; modes
                            rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode))

    (you can write your own snippet with a mirror but I think it is easier to use the ones that already exist)

  2. Open some TS project (I used this one)
  3. Install ts-ls and eslint with lsp-install-server
  4. Open some ts file, make sure company-mode and yas-minor-mode are on
  5. Define some variable, e.g. const someVariable = "some value"
  6. expand clo snippet
  7. write som and wait for it to show autocompletion
  8. try to autocomplete

Expected behavior

The expected behaviour should be:


console.log('someVariable: ', someVariable)

// but what we get is:

console.log('someVsomeVariablesomeVsomeVariable)

### Which Language Server did you use?

`eslint`, `ts-ls`, `typescript-mode`

### OS

MacOS

### Error callstack

_No response_

### Anything else?

_No response_
yyoncho commented 3 years ago

This will be very hard to fix I guess. The issue is in the completion and the code there is very tricky(since the protocol is very complex).

viglioni commented 3 years ago

Is there any way to avoid eslint/lsp to format things while they are typed/autocompleted? Because I think it would be a workaround to this problem

kiennq commented 3 years ago

Note: if only either one of these backends is on, this bug does not occur.

So does that mean eslint is changing text as well when the snippet expansion happens?

viglioni commented 3 years ago

So does that mean eslint is changing text as well when the snippet expansion happens?

AFAIK yes

ramblehead commented 3 years ago

Might be related: https://github.com/company-mode/company-mode/issues/1241

ramblehead commented 3 years ago

@Viglioni company-mode/company-mode#1241 is now fixed upstream. Could you update your company-mode and check if it fixes Subj.?

viglioni commented 3 years ago

Sorry for the delay.

Unfortunately still with the same error :(

Version: 20211024.2305

TBH I didn't know if I should open the issue here or in the Company project, but since it only happens with ts-ls + eslint I chose to open here