Merge blank lines upward instead of into the table - #59
Merged
Conversation
removeLeadingBlankParagraph deleted [tableStart-1, tableStart) -- exactly the newline Google refuses to delete unless the table goes with it. The call sat in a try/catch, so every attempt failed quietly and the blank stayed: suppressLeadingBlank has never actually suppressed anything. Deleting the newline of the paragraph *above* the blank merges the blank into it instead. The surviving paragraph keeps that paragraph's text and style, and the newline in front of the table is never touched. Applied to what the document should hold anyway -- one blank after body text, none after a heading -- so doubles collapse and a rewrite leaves no gap where content used to be. It now runs on the push path too, which is where a wholesale rewrite strands them. Closes #58 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Merging a blank upward reached for `above.endIndex - 1` even when the
element above was a table, whose end Google refuses to delete without the
whole element. Against a real document that failed the request outright:
Invalid requests[0].deleteContentRange {984,985}
A blank between two tables has nothing above it whose newline may be
taken, so it stays -- deleting its own newline is exactly what the API
rejects. The comment already said as much; the code did not.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
removeLeadingBlankParagraphdeleted[tableStart - 1, tableStart)—exactly the range the API rejects:
The call sat in a
try/catchthat logged and moved on, so every attemptfailed quietly and the blank stayed.
suppressLeadingBlankhas neversuppressed anything.
Fix. Delete the newline of the paragraph above the blank instead.
The blank merges into it, the surviving paragraph keeps that paragraph's
text and style, and the newline in front of the table is never touched.
Targeted at what the document should hold anyway — one blank after body
text, which separates the two, none after a heading, which already
carries space below it. Doubles collapse, and a rewrite leaves no gap
where content used to be. It now runs on the push path as well, which is
where a wholesale rewrite strands them.
Verification
Four tests, mutation-checked against the old range: restoring
[tableStart-1, tableStart)fails three of them, includingnever deletes the newline that belongs to the table. They assert the
ranges that actually reach
batchUpdate.pnpm test1039 passed / 63 files · typecheck clean · lint clean.Closes #58
🤖 Generated with Claude Code