| ... | ... | @@ -23,8 +23,6 @@ import { |
| 23 | 23 | terminalGridCellAt, |
| 24 | 24 | terminalScrollbarGeometry, |
| 25 | 25 | terminalScrollbarOffsetAtPointer, |
| 26 | | terminalLinkAtColumn, |
| 27 | | terminalLinkAtPosition, |
| 28 | 26 | terminalLinkAtPositionWithRange, |
| 29 | 27 | terminalContentOriginY, |
| 30 | 28 | terminalFontFamily, |
| ... | ... | @@ -433,7 +431,7 @@ describe("shouldBlinkTerminalCursor", () => { |
| 433 | 431 | }); |
| 434 | 432 | }); |
| 435 | 433 | |
| 436 | | describe("terminalLinkAtColumn", () => { |
| 434 | describe("terminalLinkAtPositionWithRange", () => { |
| 437 | 435 | it("maps terminal cells to UTF-16 offsets after a wide emoji", () => { |
| 438 | 436 | const cells = [ |
| 439 | 437 | cell("🙂"), |
| ... | ... | @@ -450,9 +448,11 @@ describe("terminalLinkAtColumn", () => { |
| 450 | 448 | wrapsToNext: false, |
| 451 | 449 | }; |
| 452 | 450 | |
| 453 | | expect(terminalLinkAtColumn(row, 2)).toBe("https://t3.codes"); |
| 454 | | expect(terminalLinkAtColumn(row, cells.length - 1)).toBe("https://t3.codes"); |
| 455 | | expect(terminalLinkAtColumn(row, 0)).toBeNull(); |
| 451 | expect(terminalLinkAtPositionWithRange([row], 0, 2)?.text).toBe("https://t3.codes"); |
| 452 | expect(terminalLinkAtPositionWithRange([row], 0, cells.length - 1)?.text).toBe( |
| 453 | "https://t3.codes", |
| 454 | ); |
| 455 | expect(terminalLinkAtPositionWithRange([row], 0, 0)).toBeNull(); |
| 456 | 456 | expect(terminalLinkAtPositionWithRange([row], 0, 8)?.range).toEqual({ |
| 457 | 457 | start: { x: 2, y: 0 }, |
| 458 | 458 | end: { x: cells.length - 1, y: 0 }, |
| ... | ... | @@ -473,10 +473,10 @@ describe("terminalLinkAtColumn", () => { |
| 473 | 473 | row("C:\\repo\\file.ts", false), |
| 474 | 474 | ]; |
| 475 | 475 | |
| 476 | | expect(terminalLinkAtPosition(rows, 0, 8)).toBe("https://example.com/reference"); |
| 477 | | expect(terminalLinkAtPosition(rows, 1, 4)).toBe("https://example.com/reference"); |
| 478 | | expect(terminalLinkAtPosition(rows, 2, 2)).toBe("~/project/file"); |
| 479 | | expect(terminalLinkAtPosition(rows, 3, 4)).toBe("C:\\repo\\file.ts"); |
| 476 | expect(terminalLinkAtPositionWithRange(rows, 0, 8)?.text).toBe("https://example.com/reference"); |
| 477 | expect(terminalLinkAtPositionWithRange(rows, 1, 4)?.text).toBe("https://example.com/reference"); |
| 478 | expect(terminalLinkAtPositionWithRange(rows, 2, 2)?.text).toBe("~/project/file"); |
| 479 | expect(terminalLinkAtPositionWithRange(rows, 3, 4)?.text).toBe("C:\\repo\\file.ts"); |
| 480 | 480 | expect(terminalLinkAtPositionWithRange(rows, 1, 4)).toEqual({ |
| 481 | 481 | text: "https://example.com/reference", |
| 482 | 482 | range: { |
| ... | ... | @@ -495,13 +495,13 @@ describe("terminalLinkAtColumn", () => { |
| 495 | 495 | }); |
| 496 | 496 | // The head of the wrapped line scrolled above the viewport. |
| 497 | 497 | const headCut = [row("ple.com/missing", true), row("head", true)]; |
| 498 | | expect(terminalLinkAtPosition(headCut, 0, 4)).toBeNull(); |
| 498 | expect(terminalLinkAtPositionWithRange(headCut, 0, 4)).toBeNull(); |
| 499 | 499 | // The bottom row soft-wraps on below the viewport. |
| 500 | 500 | const tailCut = [row("https://t3.codes", false, true)]; |
| 501 | | expect(terminalLinkAtPosition(tailCut, 0, 8)).toBeNull(); |
| 501 | expect(terminalLinkAtPositionWithRange(tailCut, 0, 8)).toBeNull(); |
| 502 | 502 | // A partial bottom row is provably complete and still resolves. |
| 503 | 503 | const complete = [row("https://t3.codes", false), row("", false)]; |
| 504 | | expect(terminalLinkAtPosition(complete, 0, 8)).toBe("https://t3.codes"); |
| 504 | expect(terminalLinkAtPositionWithRange(complete, 0, 8)?.text).toBe("https://t3.codes"); |
| 505 | 505 | // A wide grapheme earlier in the row must not break truncation detection: |
| 506 | 506 | // the soft-wrap flag decides, not string-length-versus-cell-count. |
| 507 | 507 | const wideFull: GhosttyRow = { |
| ... | ... | @@ -514,7 +514,7 @@ describe("terminalLinkAtColumn", () => { |
| 514 | 514 | isWrapContinuation: false, |
| 515 | 515 | wrapsToNext: true, |
| 516 | 516 | }; |
| 517 | | expect(terminalLinkAtPosition([wideFull], 0, 8)).toBeNull(); |
| 517 | expect(terminalLinkAtPositionWithRange([wideFull], 0, 8)).toBeNull(); |
| 518 | 518 | // Unwritten trailing cells prove the bottom row is complete. |
| 519 | 519 | const unwrittenTail: GhosttyRow = { |
| 520 | 520 | cells: [ |
| ... | ... | @@ -526,7 +526,7 @@ describe("terminalLinkAtColumn", () => { |
| 526 | 526 | isWrapContinuation: false, |
| 527 | 527 | wrapsToNext: false, |
| 528 | 528 | }; |
| 529 | | expect(terminalLinkAtPosition([unwrittenTail], 0, 8)).toBe("https://t3.codes"); |
| 529 | expect(terminalLinkAtPositionWithRange([unwrittenTail], 0, 8)?.text).toBe("https://t3.codes"); |
| 530 | 530 | }); |
| 531 | 531 | }); |
| 532 | 532 | |