[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 85a20da 482/495: Only fontify ident keys in compos
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 85a20da 482/495: Only fontify ident keys in composite literals |
Date: |
Sat, 7 Aug 2021 09:06:13 -0400 (EDT) |
branch: elpa/go-mode
commit 85a20dac6cee1e4bcfff554a665bcb7cd21dc0d9
Author: Muir Manders <muir@mnd.rs>
Commit: Peter Sanford <psanford@sanford.io>
Only fontify ident keys in composite literals
Previously we were fontifying things like selectors and binary
expressions in composite literals. For example, we fontified "baz" in:
foo{
bar.baz: 123,
bar + baz: 123,
}
Now we are more careful to only fontify composite literal key
identifiers preceded by "," or "{".
Closes: #337 [via git-merge-pr]
---
go-mode.el | 28 ++++++++++++++++------------
test/go-font-lock-test.el | 8 +++++++-
2 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index a3fc9c0..e0ba615 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1629,18 +1629,22 @@ We are looking for the right-hand-side of the type
alias"
(not found-match)
(re-search-forward go--label-re end t))
- (setq found-match (or
- ;; Composite literal field names, e.g. "Foo{Bar:".
Note
- ;; that this gives false positives for literal maps,
- ;; arrays, and slices.
- (go--in-composite-literal-p)
-
- ;; We are a label definition if we are at the
beginning
- ;; of the line.
- (save-excursion
- (goto-char (match-beginning 1))
- (skip-syntax-backward " ")
- (bolp)))))
+ (save-excursion
+ (goto-char (match-beginning 1))
+ (skip-syntax-backward " ")
+
+ (setq found-match (or
+ ;; We are a label/field name if we are at the
+ ;; beginning of the line.
+ (bolp)
+
+ ;; Composite literal field names, e.g. "Foo{Bar:".
Note
+ ;; that this gives false positives for literal maps,
+ ;; arrays, and slices.
+ (and
+ (or (eq (char-before) ?,) (eq (char-before) ?{))
+ (go--in-composite-literal-p))))))
+
found-match))
(defun go--parameter-list-type (end)
diff --git a/test/go-font-lock-test.el b/test/go-font-lock-test.el
index b38bd00..e2498ee 100644
--- a/test/go-font-lock-test.el
+++ b/test/go-font-lock-test.el
@@ -106,7 +106,13 @@ CbarC: baz,
CbarC: baz,
}, {
CbarC: baz,
-}}"))
+}}")
+
+ (go--should-fontify "TsomeMapT{
+foo.Zar: baz,
+a + b: 3,
+a-b: 4,
+}"))
(ert-deftest go--fontify-slices-arrays-maps ()
(go--should-fontify "[]TfooT")
- [nongnu] elpa/go-mode 13e9f22 428/495: Fix go-rename when buffer is not visiting any file, (continued)
- [nongnu] elpa/go-mode 13e9f22 428/495: Fix go-rename when buffer is not visiting any file, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9ab06b3 443/495: indent: fix nested dangling lines that don't use parens, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 6d58e9d 442/495: indent: fix case statement in func in composite literal, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 592bd4b 440/495: indent: fix various cases with dangling operators, ELPA Syncer, 2021/08/07
- [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 <=
- [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, 2021/08/07
- [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