Commit 1ec23c7
committed
fix: preserve comments between node and comma in separated lists (#684)
`gen_node_with_separator` emitted the auto-inserted comma immediately
after the node, then ran the regular trailing-comments path which only
emits same-line comments. Multi-line comments living between the node
end and the comma — e.g.
foo(
a
// comment
, b);
— were therefore captured by `trailing_comments_with_previous` but
filtered out by `get_trailing_comments_same_line` and lost.
Collect the comma token's leading comments that sit on lines after the
node end, mark them handled via `gen_comment_collection`, and emit them
after the separator. Result:
foo(
a,
// comment
b,
);
Applies to anything routed through `gen_node_with_separator`: call
arguments, array literals, object literals, function parameters, etc.1 parent f7dd1f3 commit 1ec23c7
2 files changed
Lines changed: 114 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8047 | 8047 | | |
8048 | 8048 | | |
8049 | 8049 | | |
| 8050 | + | |
| 8051 | + | |
| 8052 | + | |
| 8053 | + | |
| 8054 | + | |
| 8055 | + | |
| 8056 | + | |
| 8057 | + | |
| 8058 | + | |
8050 | 8059 | | |
8051 | 8060 | | |
8052 | 8061 | | |
8053 | 8062 | | |
8054 | 8063 | | |
8055 | 8064 | | |
8056 | 8065 | | |
| 8066 | + | |
8057 | 8067 | | |
8058 | 8068 | | |
8059 | 8069 | | |
| 8070 | + | |
8060 | 8071 | | |
8061 | 8072 | | |
8062 | 8073 | | |
| |||
8073 | 8084 | | |
8074 | 8085 | | |
8075 | 8086 | | |
| 8087 | + | |
| 8088 | + | |
| 8089 | + | |
| 8090 | + | |
| 8091 | + | |
| 8092 | + | |
| 8093 | + | |
| 8094 | + | |
| 8095 | + | |
| 8096 | + | |
| 8097 | + | |
| 8098 | + | |
| 8099 | + | |
| 8100 | + | |
| 8101 | + | |
| 8102 | + | |
| 8103 | + | |
| 8104 | + | |
| 8105 | + | |
| 8106 | + | |
| 8107 | + | |
| 8108 | + | |
| 8109 | + | |
| 8110 | + | |
| 8111 | + | |
| 8112 | + | |
| 8113 | + | |
| 8114 | + | |
| 8115 | + | |
| 8116 | + | |
| 8117 | + | |
| 8118 | + | |
8076 | 8119 | | |
8077 | 8120 | | |
8078 | 8121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
0 commit comments