diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 3f88bb2606..1de3cb5796 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -743,4 +743,21 @@ fn func(foo: i32) { if true { <|>foo; }; } &["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"], + ); + } } diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index f99984fe0f..f8cf1e3eb4 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs @@ -126,8 +126,8 @@ pub trait DocCommentsOwner: AstNode { // Determine if the prefix or prefix + 1 char is stripped let pos = - if line.chars().nth(prefix_len).map(|c| c.is_whitespace()).unwrap_or(false) { - prefix_len + 1 + if let Some(ws) = line.chars().nth(prefix_len).filter(|c| c.is_whitespace()) { + prefix_len + ws.len_utf8() } else { prefix_len };