Skip to content

add forward delete line + fix delete backward line - #6

Merged
trueadm merged 1 commit into
mainfrom
forward-delete-line
Jan 19, 2021
Merged

trueadm merged 1 commit into
mainfrom
forward-delete-line

Conversation

@feedthejim

Copy link
Copy Markdown

Adding this command and fix a bug on both at the same time we missed the behaviour for deleting empty lines.

Testable with alt + delete I think.

It's still a bit flaky with copy/pasted stuff but I'm looking into it.

@feedthejim
feedthejim requested a review from trueadm January 19, 2021 15:09
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 19, 2021

@trueadm trueadm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice one!

@trueadm
trueadm merged commit 5f085c1 into main Jan 19, 2021
@trueadm
trueadm deleted the forward-delete-line branch January 19, 2021 16:01
zurfyx pushed a commit that referenced this pull request Jul 26, 2022
Added dependency array to useEffect
etrepum referenced this pull request in etrepum/lexical May 10, 2026
The PR meta#8482 suffix-incremental fast path was unconditionally clearing
`subTreeTextFormat` / `subTreeTextStyle` after the suffix walk, on the
assumption that the parent's first text descendant always lived in the
non-dirty prefix. That assumption fails when the prefix has no text
descendants at all (e.g. linebreak-only prefix + final text node), and
the parent's `__textFormat` / `__textStyle` then go stale after a
format toggle on the suffix's first text descendant.

Replace the clear with an O(1) probe:

  - Cache `__lexicalFirstTextKey: NodeKey | null` on each element DOM
    alongside `__lexicalTextContent`. It records the deep first-text
    descendant key from the cycle that just wrote the cache.

  - Track `subTreeFirstTextKey` in module state alongside
    `subTreeTextFormat` / `subTreeTextStyle`, captured at the same
    sites.

  - In the suffix path, climb the cached key's `__parent` chain to find
    its direct-child ancestor under the reconciled element, then probe
    `dirtyChildren`: a non-dirty ancestor proves the prefix is still
    authoritative, so we recover format/style from the live next-state
    text node and let `reconcileTextFormat` no-op via equality. A dirty
    ancestor (or missing key) means the suffix-derived values stay.

Walk depth is bounded by tree depth from text to its parent element
(typically 1). Memory cost is one extra NodeKey slot per element DOM.

Also adds the matching format-capture rule (`if isTextNode && format
=== null then capture`) to the suffix walks in both same-size and
size-delta paths so direct-TextNode suffix children populate
subTreeTextFormat for the fallback case.

Updates AUDIT #1 (root) to lock in the new behavior, removes the now-
obsolete AUDIT #6 (made impossible by the $isRootOrShadowRoot gate),
and adds AUDIT #1 (non-root) control demonstrating that prefix-with-
text correctly suppresses suffix format propagation.

All 2499 unit tests pass.

https://claude.ai/code/session_01KR9zZXhh8Foj6QXKR8XeMs
zurfyx added a commit that referenced this pull request Oct 30, 2026
## Description

`KNOWN_OPEN` said seed 1045 loses text typed into a table a peer removes. Minimized, the seed is two operations: one client makes the paragraph inside a box a check list, which replaces the box with the list, while another inserts a table into that box. The table goes with the box (delete wins), which the Yjs 13 layouts lose too. The comment now says that. Comments only.

## Test plan

### Before

```
$ FUZZ_SEED=1045 pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/Fuzz.test.ts
[r0] C2 #4 list check paragraph("<0.14>")
[r0] A1 #6 table table(tablerow(tablecell(paragraph("<6.0>")) tablecell(paragraph("<6.1>"))) tabl in test_box
loss?: <6.0>[line,op6],<6.1>[line,op6],<6.2>[line,op6],<6.3>[line,op6]
```

(the minimized script, from the fuzz utilities' `minimize`)

### After

```
$ pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/Fuzz.test.ts
 Test Files  1 passed (1)
      Tests  16 passed (16)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants