on master help sign in
fix single-char variable names
617f09aPascal Kuthe
helix-lsp/src/snippet.rs+17−17
@@ -196,23 +196,23 @@ mod parser {
196
196
197 fn var<'a>() -> impl Parser<'a, Output = &'a str> {
197 fn var<'a>() -> impl Parser<'a, Output = &'a str> {
198 // var = [_a-zA-Z][_a-zA-Z0-9]*
198 // var = [_a-zA-Z][_a-zA-Z0-9]*
199− move |input: &'a str| match input
199+ move |input: &'a str| {
200+ input
200− .char_indices()
201+ .char_indices()
201− .take_while(|(p, c)| {
202+ .take_while(|(p, c)| {
202− *c == '_'
203+ *c == '_'
203− || if *p == 0 {
204+ || if *p == 0 {
204− c.is_ascii_alphabetic()
205+ c.is_ascii_alphabetic()
205− } else {
206+ } else {
206− c.is_ascii_alphanumeric()
207+ c.is_ascii_alphanumeric()
207− }
208+ }
208− })
209+ })
209− .last()
210+ .last()
210− {
211− Some((index, c)) if index >= 1 => {
211+ .map(|(index, c)| {
212− let index = index + c.len_utf8();
212+ let index = index + c.len_utf8();
213− Ok((&input[index..], &input[0..index]))
213+ (&input[index..], &input[0..index])
214− }
214+ })
215− _ => Err(input),
215+ .ok_or(input)
216 }
216 }
217 }
217 }
218
218