Commit 9cdcbfa
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 215f100 commit 9cdcbfa
2 files changed
Lines changed: 114 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8028 | 8028 | | |
8029 | 8029 | | |
8030 | 8030 | | |
| 8031 | + | |
| 8032 | + | |
| 8033 | + | |
| 8034 | + | |
| 8035 | + | |
| 8036 | + | |
| 8037 | + | |
| 8038 | + | |
| 8039 | + | |
8031 | 8040 | | |
8032 | 8041 | | |
8033 | 8042 | | |
8034 | 8043 | | |
8035 | 8044 | | |
8036 | 8045 | | |
8037 | 8046 | | |
| 8047 | + | |
8038 | 8048 | | |
8039 | 8049 | | |
8040 | 8050 | | |
| 8051 | + | |
8041 | 8052 | | |
8042 | 8053 | | |
8043 | 8054 | | |
| |||
8054 | 8065 | | |
8055 | 8066 | | |
8056 | 8067 | | |
| 8068 | + | |
| 8069 | + | |
| 8070 | + | |
| 8071 | + | |
| 8072 | + | |
| 8073 | + | |
| 8074 | + | |
| 8075 | + | |
| 8076 | + | |
| 8077 | + | |
| 8078 | + | |
| 8079 | + | |
| 8080 | + | |
| 8081 | + | |
| 8082 | + | |
| 8083 | + | |
| 8084 | + | |
| 8085 | + | |
| 8086 | + | |
| 8087 | + | |
| 8088 | + | |
| 8089 | + | |
| 8090 | + | |
| 8091 | + | |
| 8092 | + | |
| 8093 | + | |
| 8094 | + | |
| 8095 | + | |
| 8096 | + | |
| 8097 | + | |
| 8098 | + | |
| 8099 | + | |
8057 | 8100 | | |
8058 | 8101 | | |
8059 | 8102 | | |
| |||
| 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