[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 3497434 495/495: Fix fontification of chained map
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 3497434 495/495: Fix fontification of chained map types. |
Date: |
Sat, 7 Aug 2021 09:06:16 -0400 (EDT) |
branch: elpa/go-mode
commit 34974346d1f74fa835d745514c9fe9afccce8dae
Author: Muir Manders <muir@mnd.rs>
Commit: Peter Sanford <psanford@sanford.io>
Fix fontification of chained map types.
For types like "map[foo]map[bar]baz", we previously relied on array
fontification for fontifying "baz". In a previous commit I fixed array
fontification to not match this case (because it isn't an array). In
this commit I fix map value fontification to handle this case. In
particular, switch to a matcher func for map values so we can leave
point before the map value. For example, previously we would leave
point "|" here after matching the first map: "map[foo]map|[bar]baz"
which precludes the second "map" getting considered. Now we leave
things like "map[foo]|map[bar]baz" so the second "map" will be
considered on the next fontification iteration.
Updates #382.
Closes: #383 [via git-merge-pr]
---
go-mode.el | 13 ++++++++++++-
test/go-font-lock-test.el | 4 +++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index aa988e5..72cb8ae 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -500,7 +500,7 @@ statements."
(,(concat go-type-name-regexp "{") 1 font-lock-type-face)
;; Map value type
- (,(concat "\\_<map\\_>\\[[^]]+\\]" go-type-name-regexp) 1
font-lock-type-face)
+ (go--match-map-value 1 font-lock-type-face)
;; Map key type
(,(concat "\\_<map\\_>\\[" go-type-name-regexp) 1 font-lock-type-face)
@@ -1724,6 +1724,17 @@ We are looking for the right-hand-side of the type alias"
found-match))
+(defconst go--map-value-re
+ (concat "\\_<map\\_>\\[\\(?:\\[[^]]*\\]\\)*[^]]*\\]" go-type-name-regexp))
+
+(defun go--match-map-value (end)
+ "Search for map value types."
+ (when (re-search-forward go--map-value-re end t)
+ ;; Move point to beginning of map value in case value itself is
+ ;; also a map (we will match it next iteration).
+ (goto-char (match-beginning 1))
+ t))
+
(defconst go--label-re (concat "\\(" go-label-regexp "\\):"))
(defun go--match-ident-colon (end)
diff --git a/test/go-font-lock-test.el b/test/go-font-lock-test.el
index 9ca0f4d..c943fe4 100644
--- a/test/go-font-lock-test.el
+++ b/test/go-font-lock-test.el
@@ -130,7 +130,9 @@ a-b: 4,
(go--should-fontify "KmapK[*Tfoo.ZarT]*Tbar.ZarT")
(go--should-fontify "[]KmapK[TfooT]TbarT")
- (go--should-fontify "KmapK[[1][2][three]*Tfoo.ZarT][four][]*Tbar.ZarT"))
+ (go--should-fontify "KmapK[[1][2][three]*Tfoo.ZarT][four][]*Tbar.ZarT")
+ (go--should-fontify "KmapK[TstringT]KmapK[TstringT]Tfloat64T")
+ (go--should-fontify "KmapK[[2][c]*TintT]TboolT"))
(ert-deftest go--fontify-negation ()
;; Fontify unary "!".
- [nongnu] elpa/go-mode 35a5ddc 445/495: indent: fix decl statements with dangling "=", (continued)
- [nongnu] elpa/go-mode 35a5ddc 445/495: indent: fix decl statements with dangling "=", ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f9174b2 458/495: Improve go-dot-mod-mode font lock regexp, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 91b37c4 461/495: Disable output during indentation tests, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d712cf3 470/495: Make yes-or-no-p's PROMPT end in a space, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode bd2f6d2 467/495: Fix multiline func signature fontification., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b91a6cd 479/495: Fix composite literal key fontification, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 85a20da 482/495: Only fontify ident keys in composite literals, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 53c76cd 480/495: Speed up slow fontification after unclosed parens., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8bfc70a 484/495: Fix accidental old style backquote comma use., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d17d210 489/495: Improve go-fontify-variables logic., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3497434 495/495: Fix fontification of chained map types.,
ELPA Syncer <=
- [nongnu] elpa/go-mode 8d1594f 295/495: Automatically detect goimports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 734d523 488/495: Move some defconsts up to fix compiler warnings., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 51f507c 315/495: Complete list of commands in mode docstring, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 004575e 330/495: Don't leave godef buffer around, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 409cc64 344/495: cmd/oracle: usability improvements to "describe", "referrers", ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d9d47fa 332/495: go.tools/oracle: change -ptalog default to ""., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode bd236e5 367/495: cmd/guru: emacs: update default-directory, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2db2ff6 333/495: go.tools/oracle: change -pos flag syntax from "file pos-pos" to file:pos-pos., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 17a7d8a 370/495: cmd/guru: emacs: add function for expandiong region, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode dbc9124 378/495: Move go-guru.el to top level, ELPA Syncer, 2021/08/07