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

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

[nongnu] elpa/go-mode c576513 494/495: Fix fontification of multiplicand


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode c576513 494/495: Fix fontification of multiplicand after index expr.
Date: Sat, 7 Aug 2021 09:06:16 -0400 (EDT)

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

    Fix fontification of multiplicand after index expr.
    
    In "foo[1]*10" we were interpreting "[1]*10" as an array with element
    type "*10". At first I was going to fix the identifier regex to
    disallow leading numbers (so "10" couldn't be a type name), but that
    is involved and doesn't fix the similar case of "foo[1]*foo[2]".
    Instead fix the array type detection to disallow an identifier
    character preceding the opening bracket.
    
    Fixes #382.
---
 go-mode.el                | 2 +-
 test/go-font-lock-test.el | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/go-mode.el b/go-mode.el
index 17166e6..aa988e5 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -491,7 +491,7 @@ statements."
      (go--match-type-alias 2 font-lock-type-face)
 
      ;; Arrays/slices: []<type> | [123]<type> | [some.Const]<type> | 
[someConst]<type> | [...]<type>
-     (,(concat "\\[\\(?:[[:digit:]]+\\|" go-qualified-identifier-regexp "\\|" 
go-identifier-regexp "\\|\\.\\.\\.\\)?\\]" go-type-name-regexp) 1 
font-lock-type-face)
+     (,(concat "\\(?:^\\|[^[:word:][:multibyte:]]\\)\\[\\(?:[[:digit:]]+\\|" 
go-qualified-identifier-regexp "\\|" go-identifier-regexp "\\|\\.\\.\\.\\)?\\]" 
go-type-name-regexp) 1 font-lock-type-face)
 
      ;; Unary "!"
      ("\\(!\\)[^=]" 1 font-lock-negation-char-face)
diff --git a/test/go-font-lock-test.el b/test/go-font-lock-test.el
index e9aef31..9ca0f4d 100644
--- a/test/go-font-lock-test.el
+++ b/test/go-font-lock-test.el
@@ -126,6 +126,7 @@ a-b: 4,
   (go--should-fontify "[123]TfooT")
   (go--should-fontify "[...]TfooT")
   (go--should-fontify "[foo.Zar]TfooT")
+  (go--should-fontify "D/*DQhi*/Q[1]*TfooT")
 
   (go--should-fontify "KmapK[*Tfoo.ZarT]*Tbar.ZarT")
   (go--should-fontify "[]KmapK[TfooT]TbarT")
@@ -202,6 +203,10 @@ KforK {
   (go--should-fontify "foo, bar = baz, qux")
   (go--should-fontify "KfuncK FfooF(ViV TintT) { VbarV := baz }"))
 
+(ert-deftest go--fontify-index-multiply ()
+  (go--should-fontify "foo[1]*10 + 1")
+  (go--should-fontify "foo[1]*foo[2] + 1"))
+
 (ert-deftest go--fontify-go-dot-mod ()
   (go--should-fontify "
 KmoduleK foo



reply via email to

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