Skip to content

Commit

Permalink
Fix spacing before trailing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Xophmeister committed Jan 2, 2025
1 parent c33524f commit 00e836b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 3 additions & 0 deletions topiary-cli/tests/samples/expected/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,6 @@ multi_line_array=(
b
[1]+=foo
)

# NOTE This MUST be on the last line of this file
foo # bar
3 changes: 3 additions & 0 deletions topiary-cli/tests/samples/input/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,6 @@ multi_line_array=(
b
[1]+=foo
)

# NOTE This MUST be on the last line of this file
foo # bar
14 changes: 3 additions & 11 deletions topiary-queries/queries/bash.scm
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@
; input (i.e., blank lines shouldn't be engineered elsewhere).
; 4. A comment can never change flavour (i.e., standalone to trailing,
; or vice versa).
; 5. Trailing comments should be interposed by a space.
; 5. Trailing comments must be interposed by a space (unless they follow
; a semicolon, but we still insert the space).

; Rule 1: See @leaf rule, above

Expand All @@ -181,16 +182,7 @@
; and becoming a trailing comment. That case is satisfied by Rule 5.

; Rule 5
(
(comment) @prepend_begin_scope @append_begin_measuring_scope
.
_ @prepend_end_measuring_scope @prepend_end_scope
(#scope_id! "line_break_after_comment")
)
(
(comment) @prepend_space
(#multi_line_scope_only! "line_break_after_comment")
)
(comment) @prepend_space

;; Compound Statements and Subshells

Expand Down

0 comments on commit 00e836b

Please sign in to comment.