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

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

[nongnu] elpa/go-mode 6a64cbf 439/495: Fix indentation for composite lit


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 6a64cbf 439/495: Fix indentation for composite literal keys.
Date: Sat, 7 Aug 2021 09:06:04 -0400 (EDT)

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

    Fix indentation for composite literal keys.
    
    Incomplete composite literal keys were indenting like labels:
    
    Foo{
    Bar:
    
    instead of
    
    Foo{
      Bar:
    
    This became very noticeable after adding ":" to the electric indent
    characters. Fix by not doing the label indent if point is in a
    composite literal.
    
    Closes: #291 [via git-merge-pr]
---
 go-mode.el                                               | 3 ++-
 test/testdata/indentation_tests/composite_literal_key.go | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/go-mode.el b/go-mode.el
index d669442..de361e0 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -887,7 +887,8 @@ INDENT is the normal indent of this line, i.e. that of the 
case body."
               (looking-at (concat go-label-regexp 
":\\([[:space:]]*/.+\\)?$\\|" go--case-or-default-regexp))
               ;; don't think last part of multiline case statement is a label
               (not (go-previous-line-has-dangling-op-p))
-              (not (go--in-case-clause-list-p)))
+              (not (go--in-case-clause-list-p))
+              (not (go--in-composite-literal-p)))
 
              ;; comment attached above a "case" statement
              (go--case-comment-p indent))
diff --git a/test/testdata/indentation_tests/composite_literal_key.go 
b/test/testdata/indentation_tests/composite_literal_key.go
new file mode 100644
index 0000000..d8160db
--- /dev/null
+++ b/test/testdata/indentation_tests/composite_literal_key.go
@@ -0,0 +1,5 @@
+func _() {
+       Foo{
+               Bar:
+       }
+}



reply via email to

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