Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSServer does not get the latest version of the edited file #3856

Closed
pure-bliss opened this issue May 28, 2022 · 3 comments
Closed

TSServer does not get the latest version of the edited file #3856

pure-bliss opened this issue May 28, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@pure-bliss
Copy link

Result from CocInfo

## versions

vim version: VIM - Vi IMproved 8.2 8024827
node version: v17.9.0
coc.nvim version: 0.0.81-aede54f 2022-05-28 12:06:17 +0800
coc.nvim directory: /home/pure_bliss/.vim/plugged/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2022-05-28T11:06:06.312 INFO (pid:33857) [services] - registered service "eslint"
2022-05-28T11:06:06.314 INFO (pid:33857) [services] - ESLint state change: stopped => starting
2022-05-28T11:06:06.442 INFO (pid:33857) [services] - registered service "tsserver"
2022-05-28T11:06:06.447 INFO (pid:33857) [plugin] - coc.nvim initialized with node: v17.9.0 after 194ms
2022-05-28T11:06:06.467 INFO (pid:33857) [services] - service tsserver started
2022-05-28T11:06:06.528 INFO (pid:33857) [services] - ESLint state change: starting => running
2022-05-28T11:06:06.531 INFO (pid:33857) [services] - service eslint started
2022-05-28T11:06:08.405 INFO (pid:33857) [attach] - receive notification: showInfo []
2022-05-28T11:06:18.974 INFO (pid:33857) [attach] - receive notification: showInfo []

Describe the bug

It seems like TSServer does not get the latest version of the edited file, and shows warning for older states. If eslint-s auto fix on save is enabled, then eslint gets the older state too, and tries to fix it. For some reason this can split words in half.

  • After inserting a text TSServer doesn't seem to get the latest version, and thinks that I only typed 's' instead of 'string' (in my case)
  • Prettier auto runs on save, and for some reason it replaces 'string' with 's'
  • Pressing 'u' once (undoing changes) reverts the file to the unformatted version, with 'string' fully typed, and redoing the changes overwrites 'string' with 's' (not in video)

Reproduce the bug

Started vim with vim -u mini.vim a/test.ts

~ $ cat mini.vim
set nocompatible
set runtimepath^=/home/pure_bliss/.vim/plugged/coc.nvim
filetype plugin indent on
syntax on
set hidden
~ $ cat .vim/coc-settings.json
{
 "eslint.autoFixOnSave": true,
 "coc.preferences.formatOnSaveFiletypes": ["css", "typescript", "javascript-jsx", "typescript-tsx", "javascript", "typescriptreact"],
 "coc.preferences.jumpCommand": "vsplit",
 "diagnostic.errorSign": "❌",
 "diagnostic.warningSign": "⚠️",
 "diagnostic.infoSign": "ℹ️",
 "javascript.suggest.autoImports": true,
 "typescript.suggest.autoImports": true,
 "typescript.preferences.includePackageJsonAutoImports": "on"
}

Contents of test.ts:

export function loooooooooooooooooooooooooooooooooooooooooooooooooongfunction(a: number): any {
 return a
}

Delete 'number' or add any new type after it ' | string' and save the file. See the 'Video' section

Video

Sorry for the stretched video

2022-05-28.11-05-07.mp4

Logs created while reproducing the issue

CocCommand tsserver.openTsServerLog

tsserver.log

CocCommand workspace.showOutput tsserver

outputChannel.log

Additional information

~/.c/c/extensions $ grep '"version"' node_modules/*/package.json
node_modules/coc-css/package.json:  "version": "1.3.0",
node_modules/coc-eslint/package.json:  "version": "1.5.8",
node_modules/coc-json/package.json:  "version": "1.4.2",
node_modules/coc-prettier/package.json:  "version": "9.3.0",
node_modules/coc-tsserver/package.json:  "version": "1.10.4",
node_modules/typescript/package.json:    "version": "4.6.4",

With the 0.0.80-8f2a2dc441 version of coc.nvim this bug doesn't exist at all. This is why I created the issue here. Issue at coc-tsserver.

The working version of coc.nvim-s :CocInfo:

vim version: VIM - Vi IMproved 8.2 8024827
node version: v17.9.0
coc.nvim version: 0.0.80-8f2a2dc441
coc.nvim directory: /home/pure_bliss/.vim/plugged/coc.nvim
term: dumb
platform: linux

Video with version 0.0.80-8f2a2dc441

expected.mp4
@fannheyward
Copy link
Member

fannheyward commented May 28, 2022

Tested with latest coc/coc-tsserver/coc-eslint/coc-prettier, can't reproduce with nvim.

Added | string and save:

export function loooooooooooooooooooooooooooooooooooooooooooooooooongfunction(
  a: number | string
): any {
  return a;
}

@fannheyward
Copy link
Member

fannheyward commented May 28, 2022

Reproduced with vim 8.2 8025000.

Pressing 'u' once (undoing changes) reverts the file to the unformatted version, with 'string' fully typed, and redoing the changes overwrites 'string' with 's' (not in video)

Yes, the first time to save:

  export function loooooooooooooooooooooooooooooooooooooooooooooooooongfunction(
❌  a: number | s
❌tring): any {
    return a;
  }

Undo with u, and save again:

export function loooooooooooooooooooooooooooooooooooooooooooooooooongfunction(
  a: number | string
): any {
  return a;
}

@fannheyward
Copy link
Member

I can't 100% reproduce this with vim 8.2 8025000, only reproduced once...

@chemzqm chemzqm added the bug Something isn't working label May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants