-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
ALERename: Fix an issue with unlisted buffers #3782
Conversation
After calling ALERename on certain symbols, some files would be incorrectly replaced. The whole file would be truncated, and the only contents would be the new variable name. I was able to track it down to the following configuration: let g:ale_linters = { \ 'go': ['gopls', 'golangci-lint'], \} Whenever I tried to rename a symbol in `myfile.go`, which was referenced from an unopened file `myfile_test.go`, the whole `myfile_test.go` would be truncated. I tracked it down to `bufnr('/path/to/myfile_test.go')` returning number for a buffer that I never opened. I later noticed that this buffer was unlisted (visible only via :ls!). So there must be something in the golangci-lint linter that opens this file in the background. This fix adds a check for hidden buffers before applying code actions. Closes dense-analysis#3781
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.
Looks good to me. That’s all I can do however.
@davidatbu Is this the problem you encountered in #3478 (comment)? (I never use |
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.
Good catch!
Should the if a:should_save || l:buffer < 0
line become if a:should_save || !l:is_opened
?
Hey all, thanks for taking a look at this so quickly! After I made this change yesterday, I realized we can further improve the rename operation, since there are some cases when renaming simply fails after doing it twice. So I'm going to close this MR in favor of #3783 - I'd appreciate if you could have a look at the change there 🙇♂️ |
@liskin, this was exactly the problem i described in that comment you mentioned! Hope it gets fixed soon. |
Thanks @davidatbu, I'd appreciate if you could have a look at MR #3783 to see if you can find any bugs? I think it should all be resolved now, but it's still possible there are some corner cases I haven't tested. |
Thanks for your contributions. I'm currently toying with Neovim's built in
LSP, so i don't have the bandwidth to try this out, but if I ever revert
back to ALE, i will be sure to let you know.
…On Sun, Jun 27, 2021, 9:01 PM Jerko Steiner ***@***.***> wrote:
Thanks @davidatbu <https://github.com/davidatbu>, I'd appreciate if you
could have a look at MR #3783
<#3783> to see if you can find
any bugs?
I think it should all be resolved now, but it's still possible there are
some corner cases I haven't tested.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3782 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMQIHCZIR4VHL74GORVFG7DTU5RRHANCNFSM47LO723Q>
.
|
After calling ALERename on certain symbols, some files would be incorrectly replaced. The whole file would be truncated, and the only contents would be the new variable name.
I was able to consistently reproduce it using the following configuration:
Whenever I rename a symbol in
myfile.go
which is also referenced from an unopened filemyfile_test.go
, the wholemyfile_test.go
is truncated.I tracked it down to
bufnr('/path/to/myfile_test.go')
returning number for a buffer that I never opened.I later noticed that this buffer was unlisted (visible only via
:ls!
). So there must be something in the golangci-lint linter that opens this file in the background.This fix adds a check for hidden buffers before applying code actions.
Closes #3781