Skip to content

Fix: Backspace with Select All active merges thoughts instead of deleting them#4008

Open
Copilot wants to merge 4 commits intomainfrom
copilot/fix-delete-all-bullets-issue
Open

Fix: Backspace with Select All active merges thoughts instead of deleting them#4008
Copilot wants to merge 4 commits intomainfrom
copilot/fix-delete-all-bullets-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

When multiple thoughts are selected via Select All (cmd+opt+a) and the user presses Backspace, all thought text was merged into a single thought instead of the selected thoughts being deleted.

Root cause: deleteEmptyThoughtOrOutdent (bound to plain Backspace) called deleteEmptyThought unconditionally during multicursor execution. deleteEmptyThought merges a thought with its previous sibling — the wrong behavior when multiple thoughts are selected.

Changes

  • src/commands/deleteEmptyThoughtOrOutdent.ts
    • In exec, check hasMulticursor(state) first and dispatch deleteThoughtWithCursor() instead of deleteEmptyThought when multiselect is active
    • Add clearMulticursor: true to the multicursor config so selection is cleared post-deletion
    • Add onComplete callback to show a "Deleted N thoughts." alert, consistent with the delete command
const exec: Command['exec'] = (dispatch, getState) => {
  const state = getState()
  if (hasMulticursor(state)) {
    dispatch(deleteThoughtWithCursor())  // delete instead of merge
  } else if (state.cursorCleared) {
    dispatch(deleteEmptyThought)
  } else if (canExecuteOutdent(state)) {
    dispatch(outdent())
  } else {
    dispatch(deleteEmptyThought)
  }
}
  • src/e2e/puppeteer/__tests__/multiselect.ts
    • Add a Puppeteer test: paste 3 thoughts, select all, press Backspace, assert all thoughts are deleted

…ect active

Agent-Logs-Url: https://github.com/cybersemics/em/sessions/f9a51bb9-5342-4961-b3f8-7eb226ebbb1b

Co-authored-by: raineorshine <750276+raineorshine@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix delete button behavior when all thoughts are selected Fix: Backspace with Select All active merges thoughts instead of deleting them Mar 31, 2026
Copilot AI requested a review from raineorshine March 31, 2026 20:42
@raineorshine raineorshine marked this pull request as ready for review March 31, 2026 20:43
Copy link
Copy Markdown
Contributor

@raineorshine raineorshine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Th new puppeteer test is failing. Do not request a review until puppeteer tests pass.

- C
`)

await clickThought('C')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not guarantee that the caret moves to the beginning of the thought, which is a requirement in the Steps to Reproduce.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 4a6a603. Now using click(editableC, { edge: 'left' }) followed by waitUntil(() => window.getSelection()?.focusOffset === 0) to explicitly place the caret at the beginning of 'C' before calling selectAll, matching the Steps to Reproduce.

…r test

Agent-Logs-Url: https://github.com/cybersemics/em/sessions/4e51932c-37f1-4e6b-b5cb-c97b1dd9d434

Co-authored-by: raineorshine <750276+raineorshine@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@raineorshine raineorshine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but the puppeteer test is failing.

…ptyThoughtOrOutdent exec

Agent-Logs-Url: https://github.com/cybersemics/em/sessions/7341befb-6ac4-4afa-a4af-ddfc66547bb6

Co-authored-by: raineorshine <750276+raineorshine@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

Looks good, but the puppeteer test is failing.

Fixed in commit 3e99feb. The root cause was that setCursor (called by the multicursor loop to set each cursor) clears state.multicursors, so hasMulticursor(state) always returned false inside exec. Changed to check state.isMulticursorExecuting instead, which is set to true by the multicursor execution loop before calling exec for each cursor.

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.

[Desktop] Delete button on the keyboard delete all bullets when Select All is active

2 participants