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

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

[nongnu] elpa/go-mode d304565 474/495: Fix signature fontification after


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode d304565 474/495: Fix signature fontification after comments.
Date: Sat, 7 Aug 2021 09:06:12 -0400 (EDT)

branch: elpa/go-mode
commit d304565c2a6c8b79b495c49f293e76e527aabb12
Author: Muir Manders <muir@mnd.rs>
Commit: Peter Sanford <psanford@sanford.io>

    Fix signature fontification after comments.
    
    The comment check in go--match-param-start was breaking out of the
    loop instead of continuing to the next iteration. This was sometimes
    breaking function signature fontification when the signature was
    preceded by a comment containing "(".
---
 go-mode.el                | 32 ++++++++++++++++----------------
 test/go-font-lock-test.el |  8 +++++++-
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index 7e5ad4c..f567830 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1321,24 +1321,24 @@ declarations are also included."
   (let (found-match)
     (while (and
             (not found-match)
-            (re-search-forward (concat "\\(\\_<" go-identifier-regexp "\\)?(") 
end t)
-            (not (go-in-string-or-comment-p)))
-      (save-excursion
-        (goto-char (match-beginning 0))
-
-        (let ((name (match-string 1)))
-          (when name
-            ;; We are in a param list if "func" preceded the "(" (i.e.
-            ;; func literal), or if we are in an interface
-            ;; declaration, e.g. "interface { foo(i int) }".
-            (setq found-match (or (string= name "func") (go--in-interface-p))))
-
-          ;; Otherwise we are in a param list if our "(" is preceded
-          ;; by ") " or "func ".
-          (when (and (not found-match) (not (zerop (skip-syntax-backward " 
"))))
+            (re-search-forward (concat "\\(\\_<" go-identifier-regexp "\\)?(") 
end t))
+      (when (not (go-in-string-or-comment-p))
+        (save-excursion
+          (goto-char (match-beginning 0))
+
+          (let ((name (match-string 1)))
+            (when name
+              ;; We are in a param list if "func" preceded the "(" (i.e.
+              ;; func literal), or if we are in an interface
+              ;; declaration, e.g. "interface { foo(i int) }".
+              (setq found-match (or (string= name "func") 
(go--in-interface-p))))
+
+            ;; Otherwise we are in a param list if our "(" is preceded
+            ;; by ") " or "func ".
+            (when (and (not found-match) (not (zerop (skip-syntax-backward " 
"))))
               (setq found-match (or
                                  (eq (char-before) ?\))
-                                 (looking-back "\\_<func" (- (point) 4))))))))
+                                 (looking-back "\\_<func" (- (point) 4)))))))))
     found-match))
 
 
diff --git a/test/go-font-lock-test.el b/test/go-font-lock-test.el
index 5c1113b..2b858ea 100644
--- a/test/go-font-lock-test.el
+++ b/test/go-font-lock-test.el
@@ -37,7 +37,13 @@ KfuncK FfooF(
 ) (
   VwhyV TdothisT,
   VjustV TstopT,
-) { }"))
+) { }")
+
+  (go--should-fontify "
+D// DQ
+QD// DQ(
+QKfuncK (VfV TintT) {}
+"))
 
 (ert-deftest go--fontify-struct ()
   (go--should-fontify "KstructK { i TintT }")



reply via email to

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