Skip to content

Commit e743489

Browse files
alexander-akaitclaude
authored andcommitted
build(tooling): cut a respelling repro where the two sides part
A repro is cut to a line each way from the start, so sites running past that column printed the same prefix twice and left the respelling itself off the end — and the expectation answering for it, which reads that same string, could not see it either. `webpack-ignore/style.css` reported its escaped `@import` as a divergence for that reason and reddened the gate. Each side is now shown from where the two part, so what moved is in the line and the entry that answers for it matches.
1 parent b778bbd commit e743489

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

‎tooling/compare-css-tools.js‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,16 +1169,24 @@ const spellingFinding = (minify, css, minified, sites, respelling) => {
11691169

11701170
/**
11711171
* What the report shows for a set of sites: how they were written, and how the
1172-
* respelling writes them.
1172+
* respelling writes them, each cut to a line around the first place they part.
11731173
* @param {Site[]} sites the sites carrying the finding
11741174
* @param {Respelling} respelling how they are respelled
11751175
* @returns {string} the repro
11761176
*/
1177-
const reproOf = (sites, respelling) =>
1178-
` ${oneLine(sites.map((site) => site.text).join(" "), 76)}\n -> ${oneLine(
1179-
sites.map((site) => respelling.write(site) || site.text).join(" "),
1180-
76
1181-
)}`;
1177+
const reproOf = (sites, respelling) => {
1178+
const from = sites.map((site) => site.text).join(" ");
1179+
const to = sites.map((site) => respelling.write(site) || site.text).join(" ");
1180+
// Shown from where they part rather than from the start, which for sites
1181+
// past the line is the same prefix twice with the respelling itself cut off
1182+
// — where the entry answering for it, read off this string, misses it too.
1183+
let at = 0;
1184+
while (at < from.length && at < to.length && from[at] === to[at]) at++;
1185+
const start = at < 60 ? 0 : at - 16;
1186+
const cut = (/** @type {string} */ text) =>
1187+
start === 0 ? text : `…${text.slice(start)}`;
1188+
return ` ${oneLine(cut(from), 76)}\n -> ${oneLine(cut(to), 76)}`;
1189+
};
11821190

11831191
/**
11841192
* Every respelling this stylesheet's output depends on.

0 commit comments

Comments
 (0)