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

Fix end line number when it exceeds the file #4130

Merged
merged 1 commit into from
Apr 1, 2022

Conversation

skyfmmf
Copy link
Contributor

@skyfmmf skyfmmf commented Mar 31, 2022

If the end of the error exceeds the file, set it to the last line, similarly as it is done with the beginning of the error.

This issue was noticed by vim getting killed because of out of memory. The reason was that rust-analyzer delivered a very large number for the end line of an error (4294967295) due to an underflow bug (rust-lang/rust-analyzer#11866). Ale fixed the beginning of the error to line 1 and then tried to generate a list of the lines to highlight (https://github.com/dense-analysis/ale/blob/v3.2.0/autoload/ale/highlight.vim#L80). This list is very large, actually so large that vim was automatically killed because it ran out of memory.

While I don't think Ale should add workarounds for all bugs in language servers, I do think that this fix is reasonable generic and can help to mitigate future memory usage issues with error ranges larger than the current file.

If the end of the error exceeds the file, set it to the last line,
similarly as it is done with the beginning of the error.
Copy link
Contributor

@hsanson hsanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation and fix. Agree the fix is generic enough and is always good to protect ourselves from wrong data delievered from LSP, linters, and fixers.

@hsanson hsanson merged commit e81f005 into dense-analysis:master Apr 1, 2022
@skyfmmf skyfmmf deleted the fix-last-endline branch April 1, 2022 09:11
w0rp pushed a commit that referenced this pull request Apr 1, 2022
If the end of the error exceeds the file, set it to the last line,
similarly as it is done with the beginning of the error.
cyyever pushed a commit to cyyever/ale that referenced this pull request Jul 11, 2022
If the end of the error exceeds the file, set it to the last line,
similarly as it is done with the beginning of the error.
cyyever pushed a commit to cyyever/ale that referenced this pull request Jul 11, 2022
If the end of the error exceeds the file, set it to the last line,
similarly as it is done with the beginning of the error.
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

Successfully merging this pull request may close these issues.

None yet

2 participants