calva icon indicating copy to clipboard operation
calva copied to clipboard

Inconsistent formatting of defprotocol with docstring on separate line from method declaration.

Open skylize opened this issue 3 years ago • 0 comments

  • While typing, the docstring aligns with the parameters.

  • If the cursor is anywhere within the method form, then calva-fmt.formatCurrentForm follows the same rule, and aligns the docsctring to the params.

  • This only applies or gets updated for the single form containing the cursor. Move the cursor inside a different method's form, and run calva-fmt.formatCurrentForm to also format that form as described above, but again not affecting alignment of any other methods.

  • Move the cursor to where it is outside of any method expression and run calva-fmt.formatCurrentForm and a different rule takes over. All the docstrings align to the second character of the respective method name.

  • Same with other format-triggering events (such as paredit.dragSexpForward). So long as the cursor is not within a form that defines a method, all the docstrings align to a +2 character indentation.

; | for cursor

(defprotocol Foo
  (method [_] |"docstring"))

; <Enter>
(defprotocol Foo
  (method [_]
         |"docstring"))

; <calva-fmt.formatCurrentForm>
(defprotocol Foo
  (method [_]
         |"docstring"))

; <move cursor>
(defprotocol Foo
 |(method [_]
          "docstring"))

; <calva-fmt.formatCurrentForm>
(defprotocol Foo
 |(method [_]
    "docstring"))

; <move cursor>
(defprotocol Foo
  (|method [_]
     "docstring"))

; <calva-fmt.formatCurrentForm>
(defprotocol Foo
  (|method [_]
           "docstring"))

skylize avatar Nov 27 '22 23:11 skylize