[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode cf53daa 459/495: Fix indentation in naked blocks.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode cf53daa 459/495: Fix indentation in naked blocks. |
Date: |
Sat, 7 Aug 2021 09:06:08 -0400 (EDT) |
branch: elpa/go-mode
commit cf53daac1f87771b469606840bfc06c20220e198
Author: Muir Manders <muir@mnd.rs>
Commit: Peter Sanford <psanford@sanford.io>
Fix indentation in naked blocks.
We were detecting naked blocks as composite literals:
{
// this isn't a composite literal!
}
The problematic counter example is:
[]Foo{
{
One: 1,
},
{ // this line looks like naked block in isolation
Fix by invoking go--in-composite-literal-p recursively. If we are a
composite literal with implicit type name, we will be contained in
another composite literal.
Closes: #310 [via git-merge-pr]
---
go-mode.el | 23 ++++++++++++----------
.../indentation_tests/dangling_operator.go | 5 +++++
test/testdata/indentation_tests/labels.go | 4 ++++
3 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index afc1e13..1020812 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -646,16 +646,19 @@ case keyword. It returns nil for the case line itself."
(eq (char-after) ?{)
(or
- ;; Curly is preceded by non space (e.g. "Foo|{").
- (not (looking-back "[[:space:]]" (1- (point))))
-
- (and
- (progn (skip-syntax-backward " ") t)
-
- ;; Curly looks like a composite literal with implicit type
- ;; name. In particular, the curly is the first character on the
- ;; line or the previous character is a comma or colon.
- (or (bolp) (looking-back "[,:]" (1- (point)))))))))
+ ;; Curly is preceded by non space (e.g. "Foo{"), definitely
+ ;; composite literal.
+ (zerop (skip-syntax-backward " "))
+
+ ;; Curly preceded by comma or semicolon. This is a composite
+ ;; literal with implicit type name.
+ (looking-back "[,:]" (1- (point)))
+
+ ;; If we made it to the beginning of line we are either a naked
+ ;; block or a composite literal with implict type name. If we
+ ;; are the latter, we must be contained in another composite
+ ;; literal.
+ (and (bolp) (go--in-composite-literal-p))))))
(defun go--fill-prefix ()
"Return fill prefix for following comment paragraph."
diff --git a/test/testdata/indentation_tests/dangling_operator.go
b/test/testdata/indentation_tests/dangling_operator.go
index f8f77e0..a1749c7 100644
--- a/test/testdata/indentation_tests/dangling_operator.go
+++ b/test/testdata/indentation_tests/dangling_operator.go
@@ -78,6 +78,11 @@ func init() {
a,
b := 1, 2
+ {
+ a, b := 1,
+ 2
+ }
+
1 + foo(
3,
)
diff --git a/test/testdata/indentation_tests/labels.go
b/test/testdata/indentation_tests/labels.go
index 3b005bc..f5f6ac8 100644
--- a/test/testdata/indentation_tests/labels.go
+++ b/test/testdata/indentation_tests/labels.go
@@ -13,4 +13,8 @@ Label3: // Comments!
Label4:
// code
}
+
+ {
+ Label5:
+ }
}
- [nongnu] elpa/go-mode be9186c 417/495: Support remote files in `gofmt', (continued)
- [nongnu] elpa/go-mode be9186c 417/495: Support remote files in `gofmt', ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 287595a 420/495: Don't traverse symlinks when recursing directories, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b990645 425/495: Fix call expr indenting after dangling operator., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode ac6dd8c 430/495: Fix go-remove-unused-imports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e8674fe 437/495: Expand electric indent config a bit, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 6a64cbf 439/495: Fix indentation for composite literal keys., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode fb1272c 441/495: indent: fix performance in giant comments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c020e2c 456/495: Fontify type names in more places., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2a1584f 454/495: Readme: add note recommending goimports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 57becfb 460/495: Fontify type names in interface declarations, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode cf53daa 459/495: Fix indentation in naked blocks.,
ELPA Syncer <=
- [nongnu] elpa/go-mode f872781 466/495: Fontify variable names., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode acec0aa 471/495: Fix Content-Type for https://play.golang.org/share, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode cad6d0a 472/495: Fix fontification performance issue, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 1fbe6a8 490/495: Fix comment filling at start of buffer., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 5186c83 491/495: Support basic indenting in multiline comments., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c576513 494/495: Fix fontification of multiplicand after index expr., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 49a5380 493/495: Trivial fix of docstring and comment spelling typos., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 584628e 148/495: instead of killing lines, delete them, to avoid manipulating the kill ring, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode a82c165 221/495: fix the license, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 27068bb 222/495: provide configuration option for how to display coverage buffer, ELPA Syncer, 2021/08/07