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

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

[nongnu] elpa/typescript-mode d1ddaad259 089/222: Fix indentation of con


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode d1ddaad259 089/222: Fix indentation of continued expressions.
Date: Sun, 6 Feb 2022 16:59:21 -0500 (EST)

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

    Fix indentation of continued expressions.
    
    The previous algorithm would get tripped if the first part of a
    continued expression ended with a one-line comment. This comit fixes
    the issue.
---
 test-files/indentation-reference-document.ts |  4 ++++
 typescript-mode.el                           | 20 ++++++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/test-files/indentation-reference-document.ts 
b/test-files/indentation-reference-document.ts
index ff05f05e21..2ebed78697 100644
--- a/test-files/indentation-reference-document.ts
+++ b/test-files/indentation-reference-document.ts
@@ -487,3 +487,7 @@ function foo12(): void {
         a: {},
     });
 }
+
+const a =
+    1; // Blah
+const b = 2;
diff --git a/typescript-mode.el b/typescript-mode.el
index abb9af2a43..d2d73ff8e7 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -880,7 +880,20 @@ This function invokes `re-search-backward' but treats the 
buffer
 as if strings, preprocessor macros, and comments have been
 removed.
 
-If invoked while inside a macro, treat the macro as normal text."
+If invoked while inside a macro, treat the macro as normal text.
+
+IMPORTANT NOTE: searching for \"\\n\" with this function to find
+line breaks will generally not work, because the final newline of
+a one-line comment is considered to be part of the comment and
+will be skipped.  Take the following code:
+
+  let a = 1;
+  let b = 2; // Foo
+  let c = 3;
+
+If the point is in the last line, searching back for \"\\n\" will
+skip over the line with \"let b\". The newline found will be the
+one at the end of the line with \"let a\"."
   (let ((saved-point (point))
         (search-expr
          (cond ((null count)
@@ -1947,9 +1960,8 @@ See `font-lock-keywords'.")
      ;; "continuation".
      (not (looking-at "\\.\\.\\."))
      (or (typescript--looking-at-operator-p)
-         (and (typescript--re-search-backward "\n" nil t)
-              (progn
-                (skip-chars-backward " \t")
+         (and (progn
+                (typescript--backward-syntactic-ws)
                 (or (bobp) (backward-char))
                 (and (> (point) (point-min))
                      (save-excursion (backward-char) (not (looking-at 
"[/*]/")))



reply via email to

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