| ... | ... | @@ -257,13 +257,13 @@ describe.each(["native", "javascript"] as const)("%s highlighting budgets", (eng |
| 257 | 257 | expect(result.tokensByRowId["line-1"]?.some((token) => token.color !== null)).toBe(true); |
| 258 | 258 | }); |
| 259 | 259 | |
| 260 | | it("keeps long lines and unknown following syntax plain until the next hunk", async () => { |
| 260 | it("keeps only the long line plain and resumes highlighting after it", async () => { |
| 261 | 261 | const longLine = `${"x".repeat(1_001)} /*`; |
| 262 | 262 | const rows = [ |
| 263 | 263 | line(1, "export const before = 1;"), |
| 264 | 264 | line(2, longLine), |
| 265 | 265 | { kind: "comment", id: "note", commentText: "Check this", fileId: TYPESCRIPT_FILE.id }, |
| 266 | | line(3, "inside the comment */"), |
| 266 | line(3, "export const inside = 'x';"), |
| 267 | 267 | makeHunk("next-hunk"), |
| 268 | 268 | line(100, "export const after = 2;"), |
| 269 | 269 | ] satisfies ReadonlyArray<NativeReviewDiffRow>; |
| ... | ... | @@ -274,14 +274,36 @@ describe.each(["native", "javascript"] as const)("%s highlighting budgets", (eng |
| 274 | 274 | expect(result.tokensByRowId["line-2"]).toEqual([ |
| 275 | 275 | { content: longLine, color: null, fontStyle: null }, |
| 276 | 276 | ]); |
| 277 | | expect(result.tokensByRowId["line-3"]).toEqual([ |
| 278 | | { content: "inside the comment */", color: null, fontStyle: null }, |
| 279 | | ]); |
| 280 | | expect(result.tokensByRowId["line-1"]?.some((token) => token.color !== null)).toBe(true); |
| 281 | | expect(result.tokensByRowId["line-100"]?.some((token) => token.color !== null)).toBe(true); |
| 277 | for (const id of ["line-1", "line-3", "line-100"]) { |
| 278 | expect(result.tokensByRowId[id]?.some((token) => token.color !== null)).toBe(true); |
| 279 | } |
| 282 | 280 | expect(tokenization.calls.some((code) => code.includes(longLine))).toBe(false); |
| 283 | 281 | }); |
| 284 | 282 | |
| 283 | it("highlights the rows after a long line the same regardless of the first window", async () => { |
| 284 | const rows = [ |
| 285 | line(1, "export const before = 1;"), |
| 286 | line(2, `const data = "${"x".repeat(1_050)}";`), |
| 287 | line(3, "export const inside = 'x';"), |
| 288 | line(4, "export const after = 2;"), |
| 289 | ]; |
| 290 | const spanning = await highlightRows(rows); |
| 291 | const afterLongLine = await highlightNativeReviewDiffVisibleRows({ |
| 292 | rows, |
| 293 | files: [TYPESCRIPT_FILE], |
| 294 | scheme: "dark", |
| 295 | engine, |
| 296 | firstRowIndex: 2, |
| 297 | lastRowIndex: 3, |
| 298 | overscanRows: 0, |
| 299 | }); |
| 300 | |
| 301 | for (const id of ["line-3", "line-4"]) { |
| 302 | expect(spanning.tokensByRowId[id]?.some((token) => token.color !== null)).toBe(true); |
| 303 | expect(afterLongLine.tokensByRowId[id]).toEqual(spanning.tokensByRowId[id]); |
| 304 | } |
| 305 | }); |
| 306 | |
| 285 | 307 | it("preserves multiline grammar and row mapping across character-limited batches", async () => { |
| 286 | 308 | const opening = line(1, "const message = `open"); |
| 287 | 309 | const body = Array.from({ length: 40 }, (_, index) => line(index + 2, "inside ".repeat(45))); |