From dd0c3c41b927654553fa407fbb654bb3a2c64a48 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Wed, 19 Feb 2020 13:13:29 +0900 Subject: Fix a crash with non-ascii whitespace in doc-comments --- crates/ra_syntax/src/ast/traits.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_syntax/src/ast') diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index f99984fe0..f8cf1e3eb 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 }; -- cgit v1.2.3