Merge pull request #1802 from zed-industries/autoclose-with-same-start-and-end
Fix autoclose skipping when start and end are the same character
This commit is contained in:
commit
6a2dc444c6
2 changed files with 16 additions and 1 deletions
|
@ -2080,7 +2080,9 @@ impl Editor {
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if let Some(region) = autoclose_region {
|
}
|
||||||
|
|
||||||
|
if let Some(region) = autoclose_region {
|
||||||
// If the selection is followed by an auto-inserted closing bracket,
|
// If the selection is followed by an auto-inserted closing bracket,
|
||||||
// then don't insert that closing bracket again; just move the selection
|
// then don't insert that closing bracket again; just move the selection
|
||||||
// past the closing bracket.
|
// past the closing bracket.
|
||||||
|
|
|
@ -3041,6 +3041,12 @@ async fn test_autoclose_pairs(cx: &mut gpui::TestAppContext) {
|
||||||
close: false,
|
close: false,
|
||||||
newline: true,
|
newline: true,
|
||||||
},
|
},
|
||||||
|
BracketPair {
|
||||||
|
start: "\"".to_string(),
|
||||||
|
end: "\"".to_string(),
|
||||||
|
close: true,
|
||||||
|
newline: false,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
autoclose_before: "})]".to_string(),
|
autoclose_before: "})]".to_string(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -3161,6 +3167,13 @@ async fn test_autoclose_pairs(cx: &mut gpui::TestAppContext) {
|
||||||
cx.set_state("«aˇ» b");
|
cx.set_state("«aˇ» b");
|
||||||
cx.update_editor(|view, cx| view.handle_input("{", cx));
|
cx.update_editor(|view, cx| view.handle_input("{", cx));
|
||||||
cx.assert_editor_state("{«aˇ»} b");
|
cx.assert_editor_state("{«aˇ»} b");
|
||||||
|
|
||||||
|
// Autclose pair where the start and end characters are the same
|
||||||
|
cx.set_state("aˇ");
|
||||||
|
cx.update_editor(|view, cx| view.handle_input("\"", cx));
|
||||||
|
cx.assert_editor_state("a\"ˇ\"");
|
||||||
|
cx.update_editor(|view, cx| view.handle_input("\"", cx));
|
||||||
|
cx.assert_editor_state("a\"\"ˇ");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue