Files
genoffice/apps/docs/tests/tab-segment-width.test.ts
T
merrick-2002andGenOffice 80d2a4651e Sync snapshot (2026-09-17) (#463)
- MCP over HTTP: `genoffice mcp --http` serves the tool set as a Streamable HTTP server for clients on other machines, with file upload, URL inputs and result files handed back; MCP agents can also read PDF text, edit the open document and drive the visible Sheets grid
- Docs: picture-heavy documents open lazily with media served from disk (gigabyte files in seconds), files over 512 MB are refused with a message instead of a crash, long documents open and type faster, and many Word-fidelity fixes for tables (autofit width, split rows, header-row keep, page-edge borders), anchored pictures and text boxes, header/footer spacing, chart labels and EMF+ clipping, Japanese font substitution, italic and bidi runs
- Markdown: saving keeps unchanged blocks byte-for-byte and re-serializes edited blocks in the document's own conventions (plus an opt-in unchanged-source round trip); ```wavedrom fences render as timing diagrams
- Sheets: smooth scrolling, duplicate and large-range copy on big streamed workbooks; context-menu submenus reopen reliably; AI bulk-job economy rules
- App: Help → Check for Updates and an About-dialog button; the in-editor Files pane and floating Files / Outline edge tabs are removed from all editors; AI panel can dock on either side
- AI providers: DeepSeek V4.1 Flash, gpt-6-astra and Opper added, retired ids dropped, clearer error when a tool call's arguments are too large
- PPTX: chart categories honor the 1904 date system, slide text extracts in presentation order, single-quoted attributes and case-insensitive preset colors parse; backports of public PRs #432–#461

Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
2026-09-17 21:30:17 +08:00

30 lines
1.5 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { sameVisualLine, tabSegmentWidth } from '../src/renderer/editor/decoration-extensions'
const line = (left: number, top: number) => ({ left, top, bottom: top + 20 })
describe('tabSegmentWidth', () => {
it('measures a segment that stays on the tab line', () => {
expect(tabSegmentWidth(line(100, 0), line(340, 0), 600, 1)).toBe(240)
expect(tabSegmentWidth(line(100, 0), line(340, 0), 600, 2)).toBe(120)
expect(tabSegmentWidth(line(100, 0), line(80, 5), 600, 1)).toBe(0)
})
// a wrapped segment is at least the column wide; measuring its endpoints
// pinned a claim's tab to a space width when the last line ended flush right
it('treats a segment ending on a later line as column-wide', () => {
expect(tabSegmentWidth(line(100, 0), line(620, 28), 600, 1)).toBe(600)
expect(tabSegmentWidth(line(100, 0), line(90, 56), 600, 1)).toBe(600)
})
// line=177 auto: 20px inline boxes on a 15px pitch overlap, yet the next
// line's tab is not a same-line continuation (its segment measured 0 and the
// following tab chained from the first stop onto the default grid)
it('does not read an overlapping next line as the tab line', () => {
expect(tabSegmentWidth(line(100, 0), line(60, 15), 600, 1)).toBe(600)
expect(sameVisualLine(line(0, 0), line(0, 15))).toBe(false)
// spans of different sizes on one line keep matching
expect(sameVisualLine(line(0, 0), { top: 12, bottom: 18 })).toBe(true)
})
})