]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix typescript-ts-mode indentation (bug#77803)
authorKonstantin Kharlamov <Hi-Angel@yandex.ru>
Tue, 15 Apr 2025 14:34:11 +0000 (17:34 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 21 Apr 2025 20:38:20 +0000 (22:38 +0200)
Don't align variable names to their declaratory expression.

Before this commit in code like:

    const a = 1,
          b = 2;

the b would get indented to `const'.  Similarly for `var' and
`let'. The expected behavior instead is getting indented to
`typescript-ts-mode-indent-offset'.

* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--indent-rules): Indent identifiers declarations to
`typescript-ts-mode-indent-offset'.
* test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
(Lexical and variable declarations): Update test accordingly.

(cherry picked from commit 9750333dde9d23510341632d1c9a950d9c67415c)

lisp/progmodes/typescript-ts-mode.el
test/lisp/progmodes/typescript-ts-mode-resources/indent.erts

index 8474e4d89d9070c155fef47f78f0053c87a86392..9154d5cd99f7331882e995150ab8e19a6b04ae18 100644 (file)
@@ -153,7 +153,7 @@ Argument LANGUAGE is either `typescript' or `tsx'."
      ((parent-is "type_arguments") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "type_parameters") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is ,(rx (or "variable" "lexical") "_" (or "declaration" "declarator")))
-      typescript-ts-mode--anchor-decl 1)
+      parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "arguments") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "array") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "formal_parameters") parent-bol typescript-ts-mode-indent-offset)
index 0db3529522268bba2ba36b84f2407d44c0f900c3..1305029a9e150b7d96aa00cc7b1ed68ebf8ee5ce 100644 (file)
@@ -67,22 +67,22 @@ Name: Lexical and variable declarations
 =-=
 const foo = () => {
   let x = 1,
-      yyyy: {
-        [k: string | number]: string,
-      } = {
-        "foo": "foo",
-        "bar": "bar",
-      };
+    yyyy: {
+      [k: string | number]: string,
+    } = {
+      "foo": "foo",
+      "bar": "bar",
+    };
   var obar = 1,
-      fo: { [x: any]: any } = {
-        "a": 1,
-        "b": 2,
-      };
+    fo: { [x: any]: any } = {
+      "a": 1,
+      "b": 2,
+    };
   const cccc = 1,
-        bbb = {
-          "x": 0
-        },
-        ddddd = 0;
+    bbb = {
+      "x": 0
+    },
+    ddddd = 0;
   // First decls with value starting on same line
   const a = (x: string): string => {
     return x + x;