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

How to rename symbol #376

Closed
fcojavierdomenech opened this issue May 19, 2022 · 13 comments
Closed

How to rename symbol #376

fcojavierdomenech opened this issue May 19, 2022 · 13 comments

Comments

@fcojavierdomenech
Copy link

Using neovim with coc and tsserver.

Whenever I hit CocActions on a var a pop up appears with some options, but I can't find the rename one there.

How can I rename some symbol and its references?

@el-og
Copy link

el-og commented May 20, 2022

I haven't tried this myself, but there is a NOTE in README.md about that.

Note: for rename import on file rename, you have to install watchman in your $PATH.

@chemzqm
Copy link
Member

chemzqm commented May 20, 2022

It's not a code action, :h CocAction('rename')

@chemzqm chemzqm closed this as completed May 20, 2022
@fcojavierdomenech
Copy link
Author

I haven't tried this myself, but there is a NOTE in README.md about that.

Note: for rename import on file rename, you have to install watchman in your $PATH.

yeah, that works great with watchman, but it's mainly for moving/renaming files (not symbols).

@fcojavierdomenech
Copy link
Author

It's not a code action, :h CocAction('rename')

you mean <Leader>rn right?
It does not work in most cases: Invalid position for rename

@chemzqm
Copy link
Member

chemzqm commented May 20, 2022

It's expected, your cursor should under a variable.

@fcojavierdomenech
Copy link
Author

Captura de Pantalla 2022-05-20 a las 13 23 50

I guessed that too but It doesn't work

@fcojavierdomenech
Copy link
Author

Captura de Pantalla 2022-05-20 a las 13 31 11

@chemzqm
Copy link
Member

chemzqm commented May 20, 2022

Need verbose output, I can't reproduce https://github.com/neoclide/coc-tsserver#troubleshooting

@fcojavierdomenech
Copy link
Author

openTsServerLog:

{"seq":12,"type":"request","command":"documentHighlights","arguments":{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/domain/model/productId.ts","line":7,"offset":1,"filesToSearch":["/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/domain/model/productId.ts"]}}
Perf 404  [15:01:06.769] 12::documentHighlights: elapsed time (in milliseconds) 1.0711
Info 405  [15:01:06.769] response:
    {"seq":0,"type":"response","command":"documentHighlights","request_seq":12,"success":true,"body":[{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/domain/model/productId.ts","highlightSpans":[{"start":{"line":1,"offset":1},"end":{"line":1,"offset":7},"kind":"none"},{"start":{"line":2,"offset":1},"end":{"line":2,"offset":7},"kind":"none"},{"start":{"line":3,"offset":1},"end":{"line":3,"offset":7},"kind":"none"},{"start":{"line":5,"offset":1},"end":{"line":5,"offset":7},"kind":"none"},{"start":{"line":7,"offset":1},"end":{"line":7,"offset":7},"kind":"none"},{"start":{"line":9,"offset":1},"end":{"line":9,"offset":7},"kind":"none"},{"start":{"line":11,"offset":1},"end":{"line":11,"offset":7},"kind":"none"},{"start":{"line":13,"offset":1},"end":{"line":13,"offset":7},"kind":"none"}]}]}
Info 406  [15:01:14.305] request:
    {"seq":13,"type":"request","command":"documentHighlights","arguments":{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","line":17,"offset":3,"filesToSearch":["/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"]}}
Perf 407  [15:01:14.306] 13::documentHighlights: elapsed time (in milliseconds) 1.7383
Info 408  [15:01:14.306] response:
    {"seq":0,"type":"response","command":"documentHighlights","request_seq":13,"success":true,"body":[{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","highlightSpans":[{"start":{"line":17,"offset":3},"end":{"line":17,"offset":21},"contextStart":{"line":17,"offset":3},"contextEnd":{"line":17,"offset":48},"kind":"reference"},{"start":{"line":36,"offset":10},"end":{"line":36,"offset":28},"kind":"writtenReference"},{"start":{"line":54,"offset":14},"end":{"line":54,"offset":32},"kind":"reference"},{"start":{"line":58,"offset":59},"end":{"line":58,"offset":77},"kind":"reference"}]}]}
Info 409  [15:01:18.759] request:
    {"seq":14,"type":"request","command":"documentHighlights","arguments":{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","line":17,"offset":3,"filesToSearch":["/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"]}}
Perf 410  [15:01:18.760] 14::documentHighlights: elapsed time (in milliseconds) 1.1051
Info 411  [15:01:18.760] response:
    {"seq":0,"type":"response","command":"documentHighlights","request_seq":14,"success":true,"body":[{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","highlightSpans":[{"start":{"line":17,"offset":3},"end":{"line":17,"offset":21},"contextStart":{"line":17,"offset":3},"contextEnd":{"line":17,"offset":48},"kind":"reference"},{"start":{"line":36,"offset":10},"end":{"line":36,"offset":28},"kind":"writtenReference"},{"start":{"line":54,"offset":14},"end":{"line":54,"offset":32},"kind":"reference"},{"start":{"line":58,"offset":59},"end":{"line":58,"offset":77},"kind":"reference"}]}]}
Info 412  [15:01:22.735] request:
    {"seq":15,"type":"request","command":"documentHighlights","arguments":{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","line":17,"offset":3,"filesToSearch":["/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"]}}
Perf 413  [15:01:22.737] 15::documentHighlights: elapsed time (in milliseconds) 1.1419
Info 414  [15:01:22.737] response:
    {"seq":0,"type":"response","command":"documentHighlights","request_seq":15,"success":true,"body":[{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","highlightSpans":[{"start":{"line":17,"offset":3},"end":{"line":17,"offset":21},"contextStart":{"line":17,"offset":3},"contextEnd":{"line":17,"offset":48},"kind":"reference"},{"start":{"line":36,"offset":10},"end":{"line":36,"offset":28},"kind":"writtenReference"},{"start":{"line":54,"offset":14},"end":{"line":54,"offset":32},"kind":"reference"},{"start":{"line":58,"offset":59},"end":{"line":58,"offset":77},"kind":"reference"}]}]}
Info 415  [15:01:33.227] DirectoryWatcher:: Triggered with /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290 :: WatchInfo: /users/franciscojavierdomenech/workspace/my-project/new-webapp 1 undefined Config: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json WatchType: Wild card directory
Info 416  [15:01:33.227] Project: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json Detected ignored path: /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290
Info 417  [15:01:33.227] Elapsed:: 0.09258100017905235ms DirectoryWatcher:: Triggered with /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290 :: WatchInfo: /users/franciscojavierdomenech/workspace/my-project/new-webapp 1 undefined Config: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json WatchType: Wild card directory
Info 418  [15:01:33.277] DirectoryWatcher:: Triggered with /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290 :: WatchInfo: /users/franciscojavierdomenech/workspace/my-project/new-webapp 1 undefined Config: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json WatchType: Wild card directory
Info 419  [15:01:33.277] Project: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json Detected ignored path: /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290
Info 420  [15:01:33.277] Elapsed:: 0.08864900097250938ms DirectoryWatcher:: Triggered with /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290 :: WatchInfo: /users/franciscojavierdomenech/workspace/my-project/new-webapp 1 undefined Config: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json WatchType: Wild card directory

showOutput:


[Trace - 13:01:18.759] Sending request: documentHighlights (14). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "line": 17,
        "offset": 3,
        "filesToSearch": [
            "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"
        ]
}
[Trace - 13:01:18.761] Response received: documentHighlights (14). Request took 2 ms. Success: true 
Result: [
{
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "highlightSpans": [
        {
            "start": {
                "line": 17,
                "offset": 3
            },
            "end": {
                "line": 17,
                "offset": 21
            },
            "contextStart": {
                "line": 17,
                "offset": 3
            },
            "contextEnd": {
                "line": 17,
                "offset": 48
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 36,
                "offset": 10
            },
            "end": {
                "line": 36,
                "offset": 28
            },
            "kind": "writtenReference"
        },
        {
            "start": {
                "line": 54,
                "offset": 14
            },
            "end": {
                "line": 54,
                "offset": 32
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 58,
                "offset": 59
            },
            "end": {
                "line": 58,
                "offset": 77
            },
            "kind": "reference"
        }
    ]
}
]
[Trace - 13:01:22.733] TypeScript Server: trying to cancel ongoing request with sequence number 14
[Trace - 13:01:22.735] Sending request: documentHighlights (15). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "line": 17,
        "offset": 3,
        "filesToSearch": [
            "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"
        ]
}
[Trace - 13:01:22.737] Response received: documentHighlights (15). Request took 2 ms. Success: true 
Result: [
{
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "highlightSpans": [
        {
            "start": {
                "line": 17,
                "offset": 3
            },
            "end": {
                "line": 17,
                "offset": 21
            },
            "contextStart": {
                "line": 17,
                "offset": 3
            },
            "contextEnd": {
                "line": 17,
                "offset": 48
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 36,
                "offset": 10
            },
            "end": {
                "line": 36,
                "offset": 28
            },
            "kind": "writtenReference"
        },
        {
            "start": {
                "line": 54,
                "offset": 14
            },
            "end": {
                "line": 54,
                "offset": 32
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 58,
                "offset": 59
            },
            "end": {
                "line": 58,
                "offset": 77
            },
            "kind": "reference"
        }
    ]
}
]
[Trace - 13:01:24.424] TypeScript Server: trying to cancel ongoing request with sequence number 15
[Trace - 13:02:11.592] Sending request: documentHighlights (16). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "line": 17,
        "offset": 3,
        "filesToSearch": [
            "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"
        ]
}
[Trace - 13:02:11.593] Response received: documentHighlights (16). Request took 1 ms. Success: true 
Result: [
{
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "highlightSpans": [
        {
            "start": {
                "line": 17,
                "offset": 3
            },
            "end": {
                "line": 17,
                "offset": 21
            },
            "contextStart": {
                "line": 17,
                "offset": 3
            },
            "contextEnd": {
                "line": 17,
                "offset": 48
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 36,
                "offset": 10
            },
            "end": {
                "line": 36,
                "offset": 28
            },
            "kind": "writtenReference"
        },
        {
            "start": {
                "line": 54,
                "offset": 14
            },
            "end": {
                "line": 54,
                "offset": 32
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 58,
                "offset": 59
            },
            "end": {
                "line": 58,
                "offset": 77
            },
            "kind": "reference"
        }
    ]
}
]
[Trace - 13:02:12.308] TypeScript Server: trying to cancel ongoing request with sequence number 16

Thanks for the follow-up

@chemzqm
Copy link
Member

chemzqm commented May 20, 2022

Rename request not exists.

@fcojavierdomenech
Copy link
Author

I didn't see it either, but that's all the logs after doing the rename thing (same as the picture I sent you).

Maybe coc raises the error position not found even before comunicating with tsserver, which means it must be a prob related to coc instead of tsserver, who knows.

@fcojavierdomenech
Copy link
Author

man, I was about to call it a day and close everything. Then I realized I had a nvim session opened in background (I tend to do Ctrl-z for returning back to the terminal from nvim). Closed everything, tried again, just in case... and the rename action works PERFECTLY.

So, in order to reproduce the error (well, not really an error):

  • send to the background your nvim session with your project opened.
  • open a new nvim session from the same terminal
  • try the rename thing: Invalid position for rename

More than happy now knowing what was causing the issue. Thanks for the support.

@fcojavierdomenech
Copy link
Author

In case anyone ends here looking for help:
iamcco/coc-angular#58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants