aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/lib.rs2
-rw-r--r--crates/ra_ide/src/completion/presentation.rs6
-rw-r--r--crates/ra_ide/src/hover.rs17
-rw-r--r--crates/ra_mbe/src/subtree_source.rs2
-rw-r--r--crates/ra_syntax/src/ast/traits.rs4
5 files changed, 22 insertions, 9 deletions
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index a0e7fe17e..f4a7497db 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -38,7 +38,7 @@ pub struct GroupLabel(pub String);
38impl AssistLabel { 38impl AssistLabel {
39 pub(crate) fn new(label: String, id: AssistId) -> AssistLabel { 39 pub(crate) fn new(label: String, id: AssistId) -> AssistLabel {
40 // FIXME: make fields private, so that this invariant can't be broken 40 // FIXME: make fields private, so that this invariant can't be broken
41 assert!(label.chars().next().unwrap().is_uppercase()); 41 assert!(label.starts_with(|c: char| c.is_uppercase()));
42 AssistLabel { label, id } 42 AssistLabel { label, id }
43 } 43 }
44} 44}
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs
index 1a3bcffae..a524987fd 100644
--- a/crates/ra_ide/src/completion/presentation.rs
+++ b/crates/ra_ide/src/completion/presentation.rs
@@ -135,11 +135,7 @@ impl Completions {
135 let (before, after) = (&docs[..idx], &docs[idx + s.len()..]); 135 let (before, after) = (&docs[..idx], &docs[idx + s.len()..]);
136 // Ensure to match the full word 136 // Ensure to match the full word
137 if after.starts_with('!') 137 if after.starts_with('!')
138 && before 138 && !before.ends_with(|c: char| c == '_' || c.is_ascii_alphanumeric())
139 .chars()
140 .rev()
141 .next()
142 .map_or(true, |c| c != '_' && !c.is_ascii_alphanumeric())
143 { 139 {
144 // It may have spaces before the braces like `foo! {}` 140 // It may have spaces before the braces like `foo! {}`
145 match after[1..].chars().find(|&c| !c.is_whitespace()) { 141 match after[1..].chars().find(|&c| !c.is_whitespace()) {
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index 0bbaa0855..6d4416c0b 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -751,4 +751,21 @@ fn func(foo: i32) { if true { <|>foo; }; }
751 751
752 assert_eq!(hover_on, "bar") 752 assert_eq!(hover_on, "bar")
753 } 753 }
754
755 #[test]
756 fn test_hover_non_ascii_space_doc() {
757 check_hover_result(
758 "
759 //- /lib.rs
760 /// <- `\u{3000}` here
761 fn foo() {
762 }
763
764 fn bar() {
765 fo<|>o();
766 }
767 ",
768 &["fn foo()\n```\n\n<- `\u{3000}` here"],
769 );
770 }
754} 771}
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs
index eb8b79e9a..dacca8279 100644
--- a/crates/ra_mbe/src/subtree_source.rs
+++ b/crates/ra_mbe/src/subtree_source.rs
@@ -141,7 +141,7 @@ fn convert_literal(l: &tt::Literal) -> TtToken {
141} 141}
142 142
143fn convert_ident(ident: &tt::Ident) -> TtToken { 143fn convert_ident(ident: &tt::Ident) -> TtToken {
144 let kind = if let Some('\'') = ident.text.chars().next() { 144 let kind = if ident.text.starts_with('\'') {
145 LIFETIME 145 LIFETIME
146 } else { 146 } else {
147 SyntaxKind::from_keyword(ident.text.as_str()).unwrap_or(IDENT) 147 SyntaxKind::from_keyword(ident.text.as_str()).unwrap_or(IDENT)
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 {
126 126
127 // Determine if the prefix or prefix + 1 char is stripped 127 // Determine if the prefix or prefix + 1 char is stripped
128 let pos = 128 let pos =
129 if line.chars().nth(prefix_len).map(|c| c.is_whitespace()).unwrap_or(false) { 129 if let Some(ws) = line.chars().nth(prefix_len).filter(|c| c.is_whitespace()) {
130 prefix_len + 1 130 prefix_len + ws.len_utf8()
131 } else { 131 } else {
132 prefix_len 132 prefix_len
133 }; 133 };