neoclide/coc-tsserver

File rename does not update import paths due to timing issue

shiro opened this issue · 1 comments

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?

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