Skip to content

Fix end line number when it exceeds the file#4130

Merged
hsanson merged 1 commit into
dense-analysis:masterfrom
skyfmmf:fix-last-endline
Apr 1, 2022
Merged

Fix end line number when it exceeds the file#4130
hsanson merged 1 commit into
dense-analysis:masterfrom
skyfmmf:fix-last-endline

Conversation

@skyfmmf
Copy link
Copy Markdown
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
Copy Markdown
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.

2 participants