Fix mistakes in editor auto-indent test

Max Brunsfeld created

Change summary

crates/editor/src/editor.rs   | 92 ++++++++++++++++++------------------
crates/language/src/buffer.rs |  2 
2 files changed, 47 insertions(+), 47 deletions(-)

Detailed changes

crates/editor/src/editor.rs 🔗

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

crates/language/src/buffer.rs 🔗

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