mirror of
https://github.com/latex-lsp/texlab.git
synced 2025-08-04 18:58:31 +00:00
Add bounds check to prevent panic in token_at_offset
This commit is contained in:
parent
1f08c3a2c8
commit
065132f258
1 changed files with 4 additions and 0 deletions
|
@ -138,6 +138,10 @@ fn find_command_name_ast<L: rowan::Language>(
|
|||
kind: L::Kind,
|
||||
offset: TextSize,
|
||||
) -> Option<Span> {
|
||||
// `token_at_offset` will panic if offset is not within the range of `root`.
|
||||
if !root.text_range().contains(offset) {
|
||||
return None;
|
||||
}
|
||||
let token = root
|
||||
.token_at_offset(offset)
|
||||
.filter(|token| token.text_range().start() != offset)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue