Skip to content

Fix: sending several selected headings drops the last heading's cards - #51

Merged
ant981228 merged 1 commit into
ant981228:mainfrom
coralynnkc:fix/multi-heading-send
Sep 19, 2026
Merged

ant981228 merged 1 commit into
ant981228:mainfrom
coralynnkc:fix/multi-heading-send

Conversation

@coralynnkc

Copy link
Copy Markdown
Contributor

Problem

Reported against 1.01 and still present on main: select across several headings and press ` (Send to Speech) and the last heading doesn't come through properly. With H1, card1, H2, card2, H3, card3 selected from H1's text to H3's text:

  • drag ends in H3's second half → sends H1, card1, H2, card2, H3H3 arrives bare, card3 left behind
  • drag ends in H3's first half → sends H1, card1, H2, card2H3 missing entirely

Root cause: normalizeSelectionForSend rounds the selection end to the nearest top-level node boundary. Headings are flat siblings of their cards, not containers, so rounding to a heading's boundary never picks up its section. The bare-cursor path (enclosingStructureRange) already expands a heading to its section via sectionEndFromHeading; the selection path didn't.

Fix

In src/editor/send-normalize.ts:

  • If the selection ends inside a heading with any of its text selected, that heading is included. A caret at its very start (e.g. after shift-down onto the next line) still leaves it out.
  • If a heading ends the range, the range extends to the end of that heading's section (up to the next heading at the same or a higher level).
  • The collapsed-selection fallback also expands a heading to its section, so selecting text inside one heading sends that section, same as a bare cursor.

The shared normalizer is used by takeSendSlice, so Send to Speech (at cursor / at end), Send to Starred / Recipient, and Send to Dropzone all get the fix. The widened range is also reflected back as the visible selection before sending.

Test plan

  • New send-normalize cases: late end and early end in the last heading, stopping at the start of the next heading, the section stopping at a shallower heading, and a selection inside one heading's text
  • Send-related suites pass (10 files, 106 tests)
  • Manual: select H1 through H3's header text → ` → all three sections land in the speech doc

No changelog entry since there's no unreleased section yet; happy to add one wherever you'd like it.

https://claude.ai/code/session_01GX8wvCNHHvWsEyKwjqHPMo

Selecting across several headings and sending (` / Alt-` / Starred /
Dropzone) rounded the end to a top-level node boundary. Headings are
flat siblings of their cards, so the final heading either arrived bare
(its cards left behind) or, if the drag ended in its first half, was
dropped entirely. A bare cursor on a heading already sends its whole
section; the selection path now matches:

- any heading text selected at the end includes that heading (a caret
  parked at its very start, as after shift-down, still excludes it);
- a heading ending the range extends to its section end;
- the collapsed fallback expands a heading to its section too.

Claude-Session: https://claude.ai/code/session_01GX8wvCNHHvWsEyKwjqHPMo
@ant981228
ant981228 merged commit 2788c67 into ant981228:main Sep 19, 2026
3 checks passed
ant981228 added a commit that referenced this pull request Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants