Fix mistakes in editor auto-indent test

This commit is contained in:
Max Brunsfeld 2022-08-01 11:02:29 -07:00
parent a842016380
commit 04e40608a0
2 changed files with 47 additions and 47 deletions

View file

@ -8674,18 +8674,18 @@ mod tests {
// Cut an indented block, without the leading whitespace. // Cut an indented block, without the leading whitespace.
cx.set_state(indoc! {" cx.set_state(indoc! {"
const a = ( const a: B = (
b(), c(),
[c( [d(
d, e,
e f
)} )}
); );
"}); "});
cx.update_editor(|e, cx| e.cut(&Cut, cx)); cx.update_editor(|e, cx| e.cut(&Cut, cx));
cx.assert_editor_state(indoc! {" cx.assert_editor_state(indoc! {"
const a = ( const a: B = (
b(), c(),
| |
); );
"}); "});
@ -8693,83 +8693,83 @@ mod tests {
// Paste it at the same position. // Paste it at the same position.
cx.update_editor(|e, cx| e.paste(&Paste, cx)); cx.update_editor(|e, cx| e.paste(&Paste, cx));
cx.assert_editor_state(indoc! {" cx.assert_editor_state(indoc! {"
const a = ( const a: B = (
b(), c(),
c( d(
d, e,
e f
)| )|
); );
"}); "});
// Paste it at a line with a lower indent level. // Paste it at a line with a lower indent level.
cx.update_editor(|e, cx| e.paste(&Paste, cx));
cx.set_state(indoc! {" cx.set_state(indoc! {"
| |
const a = ( const a: B = (
b(), c(),
); );
"}); "});
cx.update_editor(|e, cx| e.paste(&Paste, cx)); cx.update_editor(|e, cx| e.paste(&Paste, cx));
cx.assert_editor_state(indoc! {" cx.assert_editor_state(indoc! {"
c( d(
d, e,
e f
)| )|
const a = ( const a: B = (
b(), c(),
); );
"}); "});
// Cut an indented block, with the leading whitespace. // Cut an indented block, with the leading whitespace.
cx.set_state(indoc! {" cx.set_state(indoc! {"
const a = ( const a: B = (
b(), c(),
[ c( [ d(
d, e,
e f
) )
}); });
"}); "});
cx.update_editor(|e, cx| e.cut(&Cut, cx)); cx.update_editor(|e, cx| e.cut(&Cut, cx));
cx.assert_editor_state(indoc! {" cx.assert_editor_state(indoc! {"
const a = ( const a: B = (
b(), c(),
|); |);
"}); "});
// Paste it at the same position. // Paste it at the same position.
cx.update_editor(|e, cx| e.paste(&Paste, cx)); cx.update_editor(|e, cx| e.paste(&Paste, cx));
cx.assert_editor_state(indoc! {" cx.assert_editor_state(indoc! {"
const a = ( const a: B = (
b(), c(),
c( d(
d, e,
e f
) )
|); |);
"}); "});
// Paste it at a line with a higher indent level. // Paste it at a line with a higher indent level.
cx.set_state(indoc! {" cx.set_state(indoc! {"
const a = ( const a: B = (
b(), c(),
c( d(
d, e,
e| f|
) )
); );
"}); "});
cx.update_editor(|e, cx| e.paste(&Paste, cx)); cx.update_editor(|e, cx| e.paste(&Paste, cx));
cx.set_state(indoc! {" cx.assert_editor_state(indoc! {"
const a = ( const a: B = (
b(), c(),
c( d(
d, e,
ec( f d(
d, e,
e f
)| )
|
) )
); );
"}); "});

View file

@ -1269,7 +1269,7 @@ impl Buffer {
first_line_is_new = true; first_line_is_new = true;
} }
// Avoid auto-indenting before the insertion. // Avoid auto-indenting after the insertion.
if is_block_mode { if is_block_mode {
start_column = start_columns.get(ix).copied(); start_column = start_columns.get(ix).copied();
if new_text[range_of_insertion_to_indent.clone()].ends_with('\n') { if new_text[range_of_insertion_to_indent.clone()].ends_with('\n') {