Skip to content

fix: allow backspace to move to next run#2201

Open
palmer-cl wants to merge 2 commits intomainfrom
fix/backspace-tc-ff
Open

fix: allow backspace to move to next run#2201
palmer-cl wants to merge 2 commits intomainfrom
fix/backspace-tc-ff

Conversation

@palmer-cl
Copy link
Collaborator

This is related to: #2175

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d31ddfd06c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Copy link
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

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

@palmer-cl makes sense to widen the scan past single-char runs, but removing the bound entirely can delete into a previous paragraph outside of TC mode. left two inline comments — main suggestion is using paragraph start as the bound instead of no bound.

const findPreviousTextDeleteRange = (doc, cursorPos, minPos) => {
for (let pos = cursorPos - 1; pos >= minPos; pos -= 1) {
const findPreviousTextDeleteRange = (doc, cursorPos) => {
for (let pos = cursorPos - 1; pos > 0; pos -= 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

without a lower bound, this scan can walk past paragraph boundaries and delete a character from the wrong paragraph. that only gets caught by normalizeReplaceStepSingleCharDelete in track-changes mode — in normal editing it goes through silently.

instead of removing minPos entirely, scope it to the current paragraph:

const paragraphStart = $pos.start($pos.depth);
const deleteRange = findPreviousTextDeleteRange(state.doc, $pos.pos, paragraphStart);

that still lets you cross sibling runs (fixing the single-char run issue) without leaving the paragraph.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did try this as a solution:

image

here were the results:

Screen Cast 2026-02-27 at 9 49 35 AM

@@ -109,27 +109,4 @@ describe('backspaceNextToRun', () => {
});
Copy link
Contributor

Choose a reason for hiding this comment

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

this test covers the cross-paragraph case — with a paragraph-scoped bound it should still pass. worth keeping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants