emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/typescript-mode d155a4b623 063/222: Revert indent of compl


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode d155a4b623 063/222: Revert indent of complex parameters.
Date: Sun, 6 Feb 2022 16:59:16 -0500 (EST)

branch: elpa/typescript-mode
commit d155a4b6238d40400acbbd84c6cc7fd3c5e21b16
Author: Louis-Dominique Dubeau <ldd@lddubeau.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>

    Revert indent of complex parameters.
    
    This reverts a change that was introduced by previous commits in how
    functions (arrow or regular), objects and arrays appearing as
    parameters are indented.
---
 test-files/indentation-reference-document.ts | 48 ++++++++++++++++------------
 typescript-mode.el                           | 34 +-------------------
 2 files changed, 29 insertions(+), 53 deletions(-)

diff --git a/test-files/indentation-reference-document.ts 
b/test-files/indentation-reference-document.ts
index 7a6ee48680..d6e3124f0f 100644
--- a/test-files/indentation-reference-document.ts
+++ b/test-files/indentation-reference-document.ts
@@ -312,15 +312,15 @@ function foo7b(a: string,
 function foo8(): void {
     // Arrow function in first parameter.
     foo7((a: string): Array<number> => {
-             return [1];
-         },
+        return [1];
+    },
          1);
 
     // Arrow function in first parameter, line break in parameters.
     foo7((a: string,
           b: string): Array<number> => {
-             return [1];
-         },
+        return [1];
+    },
          1);
 
     // Arrow function in second parameter.
@@ -350,21 +350,21 @@ const foo10 = (a: string, b: string): Array<number> => {
 
 // Arrow function assignment, parenthesized.
 const foo11 = ((a: string, b: string): Array<number> => {
-                   return [1];
-               });
+    return [1];
+});
 
 function foo12(): void {
     // Function in first parameter.
     foo7(function (a: string): Array<number> {
-             return [1];
-         },
+        return [1];
+    },
          1);
 
     // Function in first parameter, line break in parameters.
     foo7(function (a: string,
                    b: string): Array<number> {
-             return [1];
-         },
+        return [1];
+    },
          1);
 
     // Arrow function in second parameter.
@@ -384,15 +384,15 @@ function foo12(): void {
 
     // Function in first parameter.
     foo7(function _mip(a: string): Array<number> {
-             return [1];
-         },
+        return [1];
+    },
          1);
 
     // Function in first parameter, line break in parameters.
     foo7(function _mip(a: string,
                        b: string): Array<number> {
-             return [1];
-         },
+        return [1];
+    },
          1);
 
     // Arrow function in second parameter.
@@ -412,15 +412,15 @@ function foo12(): void {
 
     // Function in first parameter.
     foo7(function *(a: string): Array<number> {
-             return [1];
-         },
+        return [1];
+    },
          1);
 
     // Function in first parameter, line break in parameters.
     foo7(function *(a: string,
                     b: string): Array<number> {
-             return [1];
-         },
+        return [1];
+    },
          1);
 
     // Arrow function in second parameter.
@@ -440,7 +440,15 @@ function foo12(): void {
     // in the 1st or subsequent position of a call.
     function smurf(a: {}, b: {}) {}
     smurf({
-          },
+        a: {},
+    },
           {
-          });
+        a: {},
+    });
+
+    smurf({
+        a: {},
+    }, {
+        a: {},
+    });
 }
diff --git a/typescript-mode.el b/typescript-mode.el
index e69a3db45b..4b091fa64d 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1863,36 +1863,6 @@ moved on success."
     (when location
       (goto-char location))))
 
-(defun typescript--backward-to-function-start ()
-  "Search backward for the start of a function and move to it.
-
-This function moves the point to the start of the function and
-returns the point.
-
-The point must already be at the start of the parameter list.
-See `typescript--backward-to-parameter-list' for a function that
-does this.  If the point is not at the start of the parameter
-list, this function may return an incorrect result."
-  (goto-char
-   (or (condition-case nil
-           (save-excursion
-             (skip-syntax-backward " ")
-             (backward-sexp)
-             ;; First, check for an anonymous function.
-             (or (when (looking-at "function")
-                   (point))
-                 ;; Otherwise check if we have a named function.
-                 (progn
-                   (skip-syntax-backward " ")
-                   (backward-sexp)
-                   (when (looking-at "function")
-                     (point)))))
-         ;; backward-sexp may cause a scan-error if the sexp is
-         ;; incomplete.
-         (scan-error nil))
-       ;; If we get here, what we are looking at is an arrow function.
-       (point))))
-
 (defun typescript--proper-indentation (parse-status)
   "Return the proper indentation for the current line."
   (save-excursion
@@ -1919,9 +1889,7 @@ list, this function may return an incorrect result."
                    ;; This allows handling functions in parameter
                    ;; lists. Otherwise, we want to go back to the
                    ;; start of function declaration.
-                   (when (not (and (typescript--backward-to-function-start)
-                                   (eq (char-before) ?\()))
-                     (back-to-indentation))
+                   (back-to-indentation)
                    (cond (same-indent-p
                           (current-column))
                          (continued-expr-p



reply via email to

[Prev in Thread] Current Thread [Next in Thread]