Skip to content

coc -> Rename doesn't work across files #42

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

Closed
ryyppy opened this issue May 21, 2021 · 9 comments
Closed

coc -> Rename doesn't work across files #42

ryyppy opened this issue May 21, 2021 · 9 comments

Comments

@ryyppy
Copy link
Member

ryyppy commented May 21, 2021

There's an issue where a coc-rename over multiple files fails with [coc.nvim] Error on applyEdits: Cannot read property 'uri' of null

To reproduce, create the following files:

// MyFile1.res

let a = 1
// MyFile2.res

let b = MyFile1.a

Then try to coc-rename MyFile1.a to MyFile1.something, and it will first ask to load 1 file from disk, and then fail with the error message mentioned above.

My wild guess is that it's an issue with how coc interprets the rename command result. Either our LSP is not sticking to certain protocol conventions, or coc-vim is at fault. Hard to debug.

@amiralies
Copy link
Collaborator

It seems it happens because coc doesn't handle . (current path) in URIs. I think per standard it's okay to have . in uri and it should be fixed in coc rathar than our side (not sure tho).

to confirm this you can do a little hack in server to see if it works or not.
after else block in this line insert this code to remove . from URIs

    locations = locations.map(x => ({
      ...x,
      uri: x.uri
        .split('/')
        .filter(c => c !== '.')
        .join('/'),
    }));

@ryyppy
Copy link
Member Author

ryyppy commented May 24, 2021

Yeah that worked... okay, gonna report that one on the coc-vim repo then.

@ryyppy
Copy link
Member Author

ryyppy commented May 24, 2021

Okay, just so we know what we are talking about, this is how the paths look like for my specific rename query:

[
    {
        "uri": "file:///Users/ryyppy/Projects/rescript-association/vim-rescript/examples/rescript-project/././src/polySyntax.res",
        "range": {
            "start": {
                "line": 8,
                "character": 28
            },
            "end": {
                "line": 8,
                "character": 32
            }
        }
    },
    {
        "uri": "file:///Users/ryyppy/Projects/rescript-association/vim-rescript/examples/rescript-project/./src/recordExample.res",
        "range": {
            "start": {
                "line": 9,
                "character": 11
            },
            "end": {
                "line": 9,
                "character": 15
            }
        }
    },
    {
        "uri": "file:///Users/ryyppy/Projects/rescript-association/vim-rescript/examples/rescript-project/./src/recordExample.res",
        "range": {
            "start": {
                "line": 1,
                "character": 12
            },
            "end": {
                "line": 1,
                "character": 16
            }
        }
    }
]

The first uri looks weird though: ././src/....

@amiralies
Copy link
Collaborator

Yeah that worked... okay, gonna report that one on the coc-vim repo then.

I've opened an issue neoclide/coc.nvim#3104

The first uri looks weird though: ././src/....

Yeah, worth checking what's happening in analysis binary

@amiralies
Copy link
Collaborator

This is fixed on coc.nvim's master.

@ryyppy
Copy link
Member Author

ryyppy commented May 25, 2021

question is when this will be shipped in a new release.. not sure how to use that master version via Plug, and if we should provide some instructions on how to do that for the meantime.

@amiralies
Copy link
Collaborator

this installs coc from master

Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}

I suggest to wait until it get released, they release regulary so it should be shipped soon.

@amiralies
Copy link
Collaborator

This is released on release branch

@ryyppy
Copy link
Member Author

ryyppy commented Jun 14, 2021

okay nice, just tried it. Works like a charm.

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

2 participants