-
Notifications
You must be signed in to change notification settings - Fork 656
feat(docs): add find-range primitive that maps text to Document index ranges #682
Copy link
Copy link
Closed
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Motivation
The Docs API addresses every mutation by character index, but
documents.getreturns text spread across textRuns. Today, any script that wants to "do X to the literal text Y" must (1) callgog docs raw, (2) walkbody.contentconcatenating textRuns, (3) compute start/end indices itself. Every consumer reinvents this walk, and gets the whitespace / HTML-entity edge cases wrong on the way.Exposing a first-class
find-rangehelper unblocks every other "by-text" mode (insert / delete / update / format etc.) and is also the foundation for resolving comment anchors.Consumers
This is a load-bearing primitive. Direct consumers across the open enhancement set:
--at <text>on insert / delete / update / insert-person / insert-page-break — reduces to a thin wrapper oncefind-rangelands.docs comments locate— find-range applied to a comment'squotedFileContent.valuewith whitespace + HTML-entity normalisation on.docs write --check-orphans— uses find-range (via feat(docs comments): add locate subcommand to resolve a comment to a body range #687) to test whether each comment's quote survives in the incoming body.table-row / table-column / table-mergecommands — the--table=<header-text>addressing mode is a sibling pattern (table walk by first-cell text), not a strict consumer, but benefits from the same edge-case handling once it exists.docs named-rangecommands — the--at=<text>mode fornamed-range createdepends onfind-range.Repro
Today, to delete a literal phrase a script has to do this:
Proposed surface
JSON output:
{ "matches": [ {"startIndex": 1234, "endIndex": 1267, "paragraphIndex": 12, "tabId": "kix.abc"} ] }Plain output: TSV
startIndex<TAB>endIndex<TAB>paragraphIndex<TAB>tabId.Behaviour notes:
",&,',·,>,<).--fail-emptyconvention) when no matches.Acceptance criteria
--all) modes both return correct indices verified againstdocuments.get.--tab=resolution.--fail-emptyis set.References
documents.get: https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/get