mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Fix a crash with non-ascii whitespace in doc-comments
This commit is contained in:
parent
20252efb32
commit
dd0c3c41b9
2 changed files with 19 additions and 2 deletions
|
@ -743,4 +743,21 @@ fn func(foo: i32) { if true { <|>foo; }; }
|
||||||
&["u32"],
|
&["u32"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_hover_non_ascii_space_doc() {
|
||||||
|
check_hover_result(
|
||||||
|
"
|
||||||
|
//- /lib.rs
|
||||||
|
/// <- `\u{3000}` here
|
||||||
|
fn foo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bar() {
|
||||||
|
fo<|>o();
|
||||||
|
}
|
||||||
|
",
|
||||||
|
&["fn foo()\n```\n\n<- `\u{3000}` here"],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,8 +126,8 @@ pub trait DocCommentsOwner: AstNode {
|
||||||
|
|
||||||
// Determine if the prefix or prefix + 1 char is stripped
|
// Determine if the prefix or prefix + 1 char is stripped
|
||||||
let pos =
|
let pos =
|
||||||
if line.chars().nth(prefix_len).map(|c| c.is_whitespace()).unwrap_or(false) {
|
if let Some(ws) = line.chars().nth(prefix_len).filter(|c| c.is_whitespace()) {
|
||||||
prefix_len + 1
|
prefix_len + ws.len_utf8()
|
||||||
} else {
|
} else {
|
||||||
prefix_len
|
prefix_len
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue