Skip to content

Commit 201753a

Browse files
committed
fix
1 parent 30ec63f commit 201753a

File tree

3 files changed

+44
-38
lines changed

3 files changed

+44
-38
lines changed

src/languages/ts.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -397,29 +397,26 @@ export default (options = {}) => {
397397
for (let i = 0; i < node.arguments.length; i += 1) {
398398
const is_last = i === node.arguments.length - 1;
399399
const context = is_last ? final_context : child_context;
400+
const arg = node.arguments[i];
400401

401-
context.visit(node.arguments[i]);
402-
403-
if (!is_last) context.write(',');
404-
405-
const next = is_last ? node.loc.end : node.arguments[i + 1].loc.start;
402+
// special case — if final argument has a comment above it,
403+
// we make the whole sequence multiline
404+
if (
405+
is_last &&
406+
comments[comment_index] &&
407+
comments[comment_index].loc.start.line < arg.loc.start.line
408+
) {
409+
child_context.multiline = true;
410+
}
406411

407-
while (comment_index < comments.length) {
408-
const comment = comments[comment_index];
412+
context.visit(arg);
409413

410-
if (before(comment.loc.start, next)) {
411-
context.write(' ');
412-
write_comment(comment, context);
414+
if (!is_last) context.write(',');
413415

414-
if (comment.type === 'Line' || comment.value.includes('\n')) {
415-
context.newline();
416-
child_context.multiline = true;
417-
}
416+
const next = is_last ? node.loc.end : (node.arguments[i + 1]?.loc.start ?? null);
418417

419-
comment_index += 1;
420-
} else {
421-
break;
422-
}
418+
if (flush_trailing_comments(context, arg.loc.end, next)) {
419+
child_context.multiline = true;
423420
}
424421

425422
if (!is_last) context.append(join);

test/samples/large-file/expected.js

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,8 +2286,10 @@
22862286

22872287
return setMatcher(
22882288
i > 1 && elementMatcher(matchers),
2289-
i > 1 && toSelector(// If the preceding token was a descendant combinator, insert an implicit any-element `*`
2290-
tokens.slice(0, i - 1).concat({ value: tokens[i - 2].type === " " ? "*" : "" })).replace(rtrimCSS, "$1"),
2289+
i > 1 && toSelector(
2290+
// If the preceding token was a descendant combinator, insert an implicit any-element `*`
2291+
tokens.slice(0, i - 1).concat({ value: tokens[i - 2].type === " " ? "*" : "" })
2292+
).replace(rtrimCSS, "$1"),
22912293
matcher,
22922294
i < j && matcherFromTokens(tokens.slice(i, j)),
22932295
j < len && matcherFromTokens(tokens = tokens.slice(j)),
@@ -2680,8 +2682,9 @@
26802682

26812683
is(selector) {
26822684
return !!winnow(
2683-
this, // If this is a positional/relative selector, check membership in the returned set
2684-
// so $("p:first").is("p:last") won't return true for a doc with two "p".
2685+
this,
2686+
// If this is a positional/relative selector, check membership in the returned set
2687+
// so $("p:first").is("p:last") won't return true for a doc with two "p".
26852688
typeof selector === "string" && rneedsContext.test(selector) ? jQuery(selector) : selector || [],
26862689
false
26872690
).length;
@@ -2847,7 +2850,8 @@
28472850

28482851
// Locate the position of the desired element
28492852
return indexOf.call(
2850-
this, // If it receives a jQuery object, the first element is used
2853+
this,
2854+
// If it receives a jQuery object, the first element is used
28512855
elem.jquery ? elem[0] : elem
28522856
);
28532857
},
@@ -3440,12 +3444,16 @@
34403444
// state = "resolved" (i.e., fulfilled)
34413445
// state = "rejected"
34423446
state = stateString;
3443-
}, // rejected_callbacks.disable
3444-
// fulfilled_callbacks.disable
3445-
tuples[3 - i][2].disable, // rejected_handlers.disable
3446-
// fulfilled_handlers.disable
3447-
tuples[3 - i][3].disable, // progress_callbacks.lock
3448-
tuples[0][2].lock, // progress_handlers.lock
3447+
},
3448+
// rejected_callbacks.disable
3449+
// fulfilled_callbacks.disable
3450+
tuples[3 - i][2].disable,
3451+
// rejected_handlers.disable
3452+
// fulfilled_handlers.disable
3453+
tuples[3 - i][3].disable,
3454+
// progress_callbacks.lock
3455+
tuples[0][2].lock,
3456+
// progress_handlers.lock
34493457
tuples[0][3].lock
34503458
);
34513459
}
@@ -6336,10 +6344,9 @@
63366344
if (!isBorderBox && computedVal >= 0) {
63376345
// offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
63386346
// Assuming integer scroll gutter, subtract the rest and round down
6339-
delta += Math.max(0, Math.ceil(
6340-
elem["offset" + dimension[0].toUpperCase() + dimension.slice(1)] - computedVal - delta - extra - 0.5 // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
6341-
// Use an explicit zero to avoid NaN (gh-3964)
6342-
)) || 0;
6347+
delta += Math.max(0, Math.ceil(elem["offset" + dimension[0].toUpperCase() + dimension.slice(1)] - computedVal - delta - extra - 0.5)) || // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
6348+
// Use an explicit zero to avoid NaN (gh-3964)
6349+
0;
63436350
}
63446351

63456352
return delta + marginDelta;
@@ -6400,7 +6407,8 @@
64006407
dimension,
64016408
extra || (isBorderBox ? "border" : "content"),
64026409
valueIsBorderBox,
6403-
styles, // Provide the current computed size to request scroll gutter calculation (gh-3589)
6410+
styles,
6411+
// Provide the current computed size to request scroll gutter calculation (gh-3589)
64046412
val
64056413
) + "px";
64066414
}
@@ -9443,9 +9451,10 @@
94439451
} else {
94449452
complete(
94459453
xhrSuccessStatus[xhr.status] || xhr.status,
9446-
xhr.statusText, // Support: IE <=9 only
9447-
// IE9 has no XHR2 but throws on binary (trac-11426)
9448-
// For XHR2 non-text, let the caller handle it (gh-2498)
9454+
xhr.statusText,
9455+
// Support: IE <=9 only
9456+
// IE9 has no XHR2 but throws on binary (trac-11426)
9457+
// For XHR2 non-text, let the caller handle it (gh-2498)
94499458
(xhr.responseType || "text") !== "text" || typeof xhr.responseText !== "string" ? { binary: xhr.response } : { text: xhr.responseText },
94509459
xhr.getAllResponseHeaders()
94519460
);

test/samples/large-file/expected.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)