Skip to content

Alignment bug with comments/forms following a closing delimiter #525

@yuhan0

Description

@yuhan0

Expected behavior

M-x clojure-align on the following forms should be a no-op:

{:a [123
     456
     789] :b 10}

(cond foo  {:bar 1  ; initialize the Bar
            :baz 2} ; and the Baz
      quux {})

Actual behavior

The second "column" is pushed farther and farther to the right every time clojure-align is called.

{:a [123
     456
     789] :b 10}

=>

{:a       [123
           456
           789] :b 10}

=>

{:a             [123
                 456
                 789] :b 10}

=>

{:a                   [123
                       456
                       789] :b 10}

Steps to reproduce the problem

Execute clojure-align on any hashmap or function defined in clojure-cond-align-forms, which has a symbol or comment following a closing delimiter that is on a different line from its opening delimiter:

;; this is fine
{:a [1 2] ; comment
 }

;; this is also fine
{:a [[1
      2] ; comment
     3]
 }

;; but not this
{:a [1
     2
     3] ; comment
 }

The offending delimiter must belong to the second or greater "column" of the alignment

;; This is alright
(are [x y z] (= (count y) x (inc z))
  [100
   200
   300] 3 2)

;; This is not
(are [x y z] (= x (count y) (inc z))
  3 [100
     200
     300] 2)

Environment & Version information

clojure-mode version information

Include here the version string displayed by M-x clojure-mode-display-version. Here's an example:

clojure-mode (version 5.10.0)

Emacs version

26.2

Operating system

macOS 10.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions