Fix panic on paste when editing with auto-indent
Instead of accepting text as it's input by the user, we will read it out of the edit operation after it gets sanitized by the buffer.
This commit is contained in:
parent
573dd29882
commit
d3db700db4
2 changed files with 25 additions and 1 deletions
|
@ -22,6 +22,29 @@ fn init_logger() {
|
|||
}
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_line_endings(cx: &mut gpui::MutableAppContext) {
|
||||
cx.add_model(|cx| {
|
||||
let mut buffer =
|
||||
Buffer::new(0, "one\r\ntwo\rthree", cx).with_language(Arc::new(rust_lang()), cx);
|
||||
assert_eq!(buffer.text(), "one\ntwo\nthree");
|
||||
assert_eq!(buffer.line_ending(), LineEnding::Windows);
|
||||
|
||||
buffer.check_invariants();
|
||||
buffer.edit_with_autoindent(
|
||||
[(buffer.len()..buffer.len(), "\r\nfour")],
|
||||
IndentSize::spaces(2),
|
||||
cx,
|
||||
);
|
||||
buffer.edit([(0..0, "zero\r\n")], cx);
|
||||
assert_eq!(buffer.text(), "zero\none\ntwo\nthree\nfour");
|
||||
assert_eq!(buffer.line_ending(), LineEnding::Windows);
|
||||
buffer.check_invariants();
|
||||
|
||||
buffer
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_select_language() {
|
||||
let registry = LanguageRegistry::test();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue