on master help sign in
Fix erroneous indent between closers of auto-pairs (#5330)
5f2fe5fTriton171
helix-core/src/auto_pairs.rs+1−1
@@ -17,7 +17,7 @@ pub const DEFAULT_PAIRS: &[(char, char)] = &[
17];
17];
18
18
19/// The type that represents the collection of auto pairs,
19/// The type that represents the collection of auto pairs,
20−/// keyed by the opener.
20+/// keyed by both opener and closer.
21#[derive(Debug, Clone)]
21#[derive(Debug, Clone)]
22pub struct AutoPairs(HashMap<char, Pair>);
22pub struct AutoPairs(HashMap<char, Pair>);
23
23
helix-term/src/commands.rs+1−2
@@ -3173,8 +3173,7 @@ pub mod insert {
3173 let on_auto_pair = doc
3173 let on_auto_pair = doc
3174 .auto_pairs(cx.editor)
3174 .auto_pairs(cx.editor)
3175 .and_then(|pairs| pairs.get(prev))
3175 .and_then(|pairs| pairs.get(prev))
3176− .and_then(|pair| if pair.close == curr { Some(pair) } else { None })
3176+ .map_or(false, |pair| pair.open == prev && pair.close == curr);
3177− .is_some();
3178
3177
3179 let local_offs = if on_auto_pair {
3178 let local_offs = if on_auto_pair {
3180 let inner_indent = indent.clone() + doc.indent_style.as_str();
3179 let inner_indent = indent.clone() + doc.indent_style.as_str();