ananthakumaran / tide

Tide - TypeScript Interactive Development Environment for Emacs
GNU General Public License v3.0
1.46k stars 109 forks source link

tide-rename-symbol does not rename with tsserver version 4.3.5 #429

Closed vbraun closed 3 years ago

vbraun commented 3 years ago

Checklist

Relevant Version Numbers

M-x tide-verify-setup output:

tsserver version: 4.3.5

config file path: /home/vbraun/new-project/tsconfig.json

Steps to Reproduce the Bug

Expected Behavior

Symbol is renamed

Actual Behavior

Emacs prints

Renamed 0 occurences.

and nothing is renamed

Further Notes

I have an older project with an older typescript version, and there tide-rename-symbol works (same emacs, same tide)

tsserver version: 4.1.3

config file path: /home/vbraun/old-project/tsconfig.json
ananthakumaran commented 3 years ago

could you enable debug logs and check what's the request/response for this command from tsserver.

vbraun commented 3 years ago

Relevant part of the tsserver log:

Info 2227 [14:28:42.027] request:
    {"command":"configure","seq":"17","arguments":{"hostInfo":"GNU Emacs 27.2 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.29, cairo version 1.17.4)\n of 2021-06-13","file":"/home/vbraun/Talque-3/talque/frontend/projects/org-admin/standalone/src/app/grid/invite-grid/invite-grid-view.component.ts","formatOptions":{"tabSize":8,"indentSize":4,"insertSpaceAfterFunctionKeywordForAnonymousFunctions":true,"placeOpenBraceOnNewLineForFunctions":null},"preferences":{"includeCompletionsForModuleExports":true,"includeCompletionsWithInsertText":true,"allowTextChangesInNewFiles":true,"generateReturnInDocTemplate":true}}}
Info 2228 [14:28:42.027] Host configuration update for file /home/vbraun/Talque-3/talque/frontend/projects/org-admin/standalone/src/app/grid/invite-grid/invite-grid-view.component.ts
Info 2229 [14:28:42.028] response:
    {"seq":0,"type":"response","command":"configure","request_seq":"17","success":true}
Perf 2230 [14:28:42.028] 17::configure: async elapsed time (in milliseconds) 0.3520
Info 2231 [14:28:42.028] event:
    {"seq":0,"type":"event","event":"typingsInstallerPid","body":{"pid":2016073}}
Info 2232 [14:28:50.628] request:
    {"command":"rename","seq":"18","arguments":{"file":"/home/vbraun/Talque-3/talque/frontend/projects/org-admin/standalone/src/app/grid/invite-grid/invite-grid-view.component.ts","line":5,"offset":7}}
Perf 2233 [14:28:50.638] 18::rename: elapsed time (in milliseconds) 10.2710
Info 2234 [14:28:50.638] response:
    {"seq":0,"type":"response","command":"rename","request_seq":"18","success":true,"body":{"info":{"canRename":true,"displayName":"x","fullDisplayName":"x","kind":"const","kindModifiers":"","triggerSpan":{"start":{"line":5,"offset":7},"end":{"line":5,"offset":8}}},"locs":[]}}

I'm guessing this is because locs is empty. In the example I'm using an unused variable, though the variable declaration itself can be renamed??

ananthakumaran commented 3 years ago

Yes, the locs shouldn't be empty. I tested the single variable rename case and it's working on 4.2.3. So it's possible a regression on tsserver. You could report to https://github.com/microsoft/TypeScript

vbraun commented 3 years ago

When I try the same in visual studio code (1.58.2) then rename works

Info 0    [15:41:42.468] Starting TS Server
Info 1    [15:41:42.468] Version: 4.1.0-dev.20200917
[...]
Info 2841 [15:54:01.379] request:
    {"seq":149,"type":"request","command":"rename","arguments":{"file":"/home/vbraun/Talque-3/talque/frontend/projects/org-admin/standalone/src/app/grid/invite-grid/invite-grid-view.component.ts","line":4,"offset":7,"findInStrings":false,"findInComments":false}}
Perf 2842 [15:54:01.381] 149::rename: elapsed time (in milliseconds) 1.9369
Info 2843 [15:54:01.381] response:
    {"seq":0,"type":"response","command":"rename","request_seq":149,"success":true,"body":{"info":{"canRename":true,"displayName":"y","fullDisplayName":"y","kind":"const","kindModifiers":"","triggerSpan":{"start":{"line":4,"offset":7},"end":{"line":4,"offset":8}}},"locs":[{"file":"/home/vbraun/Talque-3/talque/frontend/projects/org-admin/standalone/src/app/grid/invite-grid/invite-grid-view.component.ts","locs":[{"start":{"line":4,"offset":7},"end":{"line":4,"offset":8},"contextStart":{"line":4,"offset":1},"contextEnd":{"line":4,"offset":13}}]}]}}

whereas from tide (same file & cursor position)

Info 2277 [15:46:12.998] request:
    {"command":"rename","seq":"638","arguments":{"file":"/home/vbraun/Talque-3/talque/frontend/projects/org-admin/standalone/src/app/grid/invite-grid/invite-grid-view.component.ts","line":4,"offset":7}}
Perf 2278 [15:46:13.003] 638::rename: elapsed time (in milliseconds) 5.1103
Info 2279 [15:46:13.003] response:
    {"seq":0,"type":"response","command":"rename","request_seq":"638","success":true,"body":{"info":{"canRename":true,"displayName":"x","fullDisplayName":"x","kind":"const","kindModifiers":"","triggerSpan":{"start":{"line":4,"offset":7},"end":{"line":4,"offset":8}}},"locs":[]}}

The type, findInStrings, and findInComments keys are missing from the tide request but neither seems very important...

ananthakumaran commented 3 years ago

interesting, can you confirm if the tsserver version is the same in both cases? Could you also check if configure command has any notable difference between vscode and tide

vbraun commented 3 years ago

Indeed was using code's builtin tsserver, after configuring visual studio code to use the tsserver from my workspace rename fails there, too

Info 0    [16:04:06.429] Starting TS Server
Info 1    [16:04:06.429] Version: 4.3.5
[...]
Info 2306 [16:04:38.165] request:
    {"seq":14,"type":"request","command":"rename","arguments":{"file":"/home/vbraun/Talque-3/talque/frontend/projects/org-admin/standalone/src/app/grid/invite-grid/invite-grid-view.component.ts","line":4,"offset":7,"findInStrings":false,"findInComments":false}}
Perf 2307 [16:04:38.167] 14::rename: elapsed time (in milliseconds) 2.1292
Info 2308 [16:04:38.167] response:
    {"seq":0,"type":"response","command":"rename","request_seq":14,"success":true,"body":{"info":{"canRename":true,"displayName":"x","fullDisplayName":"x","kind":"const","kindModifiers":"","triggerSpan":{"start":{"line":4,"offset":7},"end":{"line":4,"offset":8}}},"locs":[]}}
ananthakumaran commented 3 years ago

I can't reproduce the single variable rename case locally with 4.3.5. This might be potentially specific to your code. Since vscode has the same issue, I would suggest reporting it to typescript repo

tsserver version: 4.3.5
    {"command":"rename","seq":"101","arguments":{"file":"<redacted>/tide/example/test.ts","line":3,"offset":6}}
Perf 149  [19:42:02.354] 101::rename: elapsed time (in milliseconds) 4.8622
Info 150  [19:42:02.354] response:
    {"seq":0,"type":"response","command":"rename","request_seq":"101","success":true,"body":{"info":{"canRename":true,"displayName":"_xne","fullDisplayName":"_xne","kind":"var","kindModifiers":"","triggerSpan":{"start":{"line":3,"offset":5},"end":{"line":3,"offset":9}}},"locs":[{"file":"<redacted>/tide/example/test.ts","locs":[{"start":{"line":3,"offset":5},"end":{"line":3,"offset":9},"contextStart":{"line":3,"offset":1},"contextEnd":{"line":3,"offset":16}}]}]}}
vbraun commented 3 years ago

Apparently this is due to the @angular/language-service plugin, when I remove that from my tsconfig.json then rename works!

vbraun commented 3 years ago

There is already a bug report at https://github.com/angular/angular/issues/42715, closing