[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 35a5ddc 445/495: indent: fix decl statements with
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 35a5ddc 445/495: indent: fix decl statements with dangling "=" |
Date: |
Sat, 7 Aug 2021 09:06:06 -0400 (EDT) |
branch: elpa/go-mode
commit 35a5ddc1299371ea0f8f050800944e1c35806cfc
Author: Muir Manders <muir@mnd.rs>
Commit: Peter Sanford <psanford@sanford.io>
indent: fix decl statements with dangling "="
In "var", "const" and "type" statements, a dangling "=" does not
indent the following lines. We now test for this case and don't treat
the "=" as a dangling operator.
var foo =
// don't indent me
123
Note that the above is a syntax error without the comment.
---
go-mode.el | 6 ++-
test/testdata/indentation_tests/dangling_decls.go | 47 +++++++++++++++++++++++
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/go-mode.el b/go-mode.el
index 90897b5..18d048c 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -556,7 +556,11 @@ The return value is cached based on the current
`line-beginning-position'."
"Return non-nil if current line ends in a dangling operator.
The return value is not cached."
(or
- (go--line-suffix-p go-dangling-operators-regexp)
+ (and
+ (go--line-suffix-p go-dangling-operators-regexp)
+ ;; "=" does not behave like a dangling operator in decl statements.
+ (not (go--line-suffix-p "\\(?:var\\|type\\|const\\)[[:space:]].*=")))
+
;; treat comma as dangling operator in certain cases
(and
(go--line-suffix-p ",")
diff --git a/test/testdata/indentation_tests/dangling_decls.go
b/test/testdata/indentation_tests/dangling_decls.go
new file mode 100644
index 0000000..cd4f4d1
--- /dev/null
+++ b/test/testdata/indentation_tests/dangling_decls.go
@@ -0,0 +1,47 @@
+package main
+
+var foo =
+// hello
+123
+
+var foo = 123 +
+ // hello
+ 123
+
+const foo =
+// hello
+123
+
+const foo = 123 +
+ // hello
+ 123
+
+type foo =
+// hello
+int
+
+func main() {
+ var foo =
+ // hello
+ 123
+
+ var foo = 123 +
+ // hello
+ 123
+
+ const foo =
+ // hello
+ 123
+
+ const foo = 123 +
+ // hello
+ 123
+
+ type foo =
+ // hello
+ int
+
+ foo :=
+ // hello
+ 123
+}
- [nongnu] elpa/go-mode 8991b83 384/495: refactor/rename: emacs: kill go-rename buffer correctly, (continued)
- [nongnu] elpa/go-mode 8991b83 384/495: refactor/rename: emacs: kill go-rename buffer correctly, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode adea2e5 395/495: Make go-guru-build-tags a list of strings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d511e35 402/495: Replace obsolete one-argument form of ‘looking-back’., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 35f6826 404/495: Bump version to 1.5.0, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode da55ef1 413/495: Evaluate error conditions before prompting for new name, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 59dfa96 423/495: Add confirmation prompt for Playground uploads, ELPA Syncer, 2021/08/07
- [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 <=
- [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, 2021/08/07