-
Notifications
You must be signed in to change notification settings - Fork 143
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
fix: willRename source path #248
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may fix the immediate problem, but it will introduce more issues. Any pattern that doesn't start with **
will fail to match because we're passing in the absolute path to the file. The root issue here is vim's glob2regpat
does not handle **
the way we expect. See:
:echo glob2regpat('*.js')
-> \.js$
:echo glob2regpat('**/*.js')
-> /.*\.js$
:echo glob2regpat('**/**/*.js')
-> /.*/.*\.js$
This is technically correct by some definitions, but does not behave the way LSP expects.
I think the best solution we have available right now is to use the private method vim.lsp._watchfiles._match
when it's available, and fall back to glob2regpat
when it's not.
This is actually not true, try the following: local pat = vim.fn.glob2regpat("*.js")
local match = vim.fn.match("/dir/file.js", pat)
print(match) -- 9 |
Ah, I was overly broad. Yes it's true that a pattern of local pat = vim.fn.glob2regpat("src/*.js")
local match = vim.fn.match("/home/user/project/src/file.js", pat)
print(match) -- -1 |
Oh, I see. But I think it's unlikely going to happen, I think I'll update this later and use |
feeb1b7
to
8847f6b
Compare
8847f6b
to
d59d188
Compare
Thanks for the PR! |
Closes #247.
I think getting the relative path is unnecessary because the glob pattern will always match the full path, and it can mess up with some server filters, for example: tsserver uses
**/*.js
but the relative path omit the parent dir.