neoclide / coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
MIT License
1.06k stars 68 forks source link

File rename does not update import paths due to timing issue #446

Closed shiro closed 6 months ago

shiro commented 9 months ago

Hello, I'm on coc-tsserver latest master commit (9ff880e), latest watchman (2023.11.27.00-1) .

Running CocCommand workspace.renameCurrentFile with watchman installed doesn't update import paths in other files most of the time.
The odds of it working are around 10% I'd say (re-ran it like 200 times :D )

After extensive testing, it seems like the rename gets picked up by watchman just fine, the issue was with the ts-server RPC... When getEditsForFileRename gets called, it returns [].

I managed to track it down to src/server/features/updatePathOnRename.ts, if I change the line to:

private readonly _delayer = new Delayer(200);

It works 100% of the time, it seems to be a timing issue with the wait delay not being long enough. I imagine this number might have to be even bigger for slower systems, since I'm on a workstation.

Would you be open to a PR increasing it to a bigger number or do you have other ideas?

fannheyward commented 9 months ago

Thank you for your debugging and the help, PR is welcome!