fix(reflow): caret lands on wrong char in centered/right headings
The reflow caret layout hardcoded x0 = columnLeft. That matched only left-aligned lines; for the new center/right headings the line renders at a shifted x (e.g. a centered title starts ~215pt while columnLeft is the page margin ~54pt), so the frontend mapped clicks and drew the caret ~160pt off the actual glyphs. Record the line's true starting x (after lineX/center/right) as x0 instead. x0 is caret-only metadata read by the live editor — it does not affect glyph emission or the rendered page, so output is unchanged (overlay-diff gate identical: 1.70%/1.69%, STRESS PASS). Rebuilt .pyd + WASM; cache version bumped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
660649a562
commit
62c4aed48c
@@ -2982,6 +2982,12 @@ std::expected<void, EngineError> PdfiumDocument::applyEdits(const std::string& e
|
||||
if (align == "right") x = columnLeft + (columnWidth - naturalW);
|
||||
else if (align == "center") x = columnLeft + (columnWidth - naturalW) / 2.0;
|
||||
}
|
||||
// The line's TRUE starting x (after lineX/center/right). The caret layout below
|
||||
// records this as x0 so the frontend places the caret on the actual glyphs. (It
|
||||
// used to hardcode columnLeft, which only matched left-aligned lines — center/right
|
||||
// headings then mismapped clicks. x0 is caret-only metadata; it does not affect
|
||||
// glyph emission or the rendered page.)
|
||||
const double lineStartX = x;
|
||||
for (size_t k = 0; k < lw.size(); ++k) {
|
||||
size_t wi = lw[k];
|
||||
if (k > 0) {
|
||||
@@ -3026,7 +3032,7 @@ std::expected<void, EngineError> PdfiumDocument::applyEdits(const std::string& e
|
||||
x += words[wi].width;
|
||||
}
|
||||
layoutLines.push_back({
|
||||
{"baselineY", baselineY}, {"x0", columnLeft},
|
||||
{"baselineY", baselineY}, {"x0", lineStartX},
|
||||
{"fontSize", lineFontSize > 0 ? lineFontSize : leading / 1.2},
|
||||
{"text", lineText}, {"adv", adv},
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ function getModule(): Promise<PdfiumModule | null> {
|
||||
if (!modulePromise) {
|
||||
modulePromise = (async () => {
|
||||
try {
|
||||
const V = '20260617b';
|
||||
const V = '20260617c';
|
||||
const resp = await fetch(`/pdfium-engine.mjs?v=${V}`, { cache: 'no-store' });
|
||||
if (!resp.ok) throw new Error(`pdfium-engine.mjs ${resp.status}`);
|
||||
const blobUrl = URL.createObjectURL(new Blob([await resp.text()], { type: 'text/javascript' }));
|
||||
|
||||
Reference in New Issue
Block a user