Skip to content

feat(rust): replay property/sequences, with NormalizeInlineElements and JS's no-DOM-selection deletion - #149

Open
tmm wants to merge 1 commit into
rust-decorator-nodefrom
rust-property-sequences
Open

tmm wants to merge 1 commit into
rust-decorator-nodefrom
rust-property-sequences

Conversation

@tmm

@tmm tmm commented Nov 14, 2026

Copy link
Copy Markdown
Member

Description

The Rust conformance runner didn't replay property/sequences, the 81
random command sequences JS records on a rich-text editor with lists,
check lists, links, hashtags, code and history.

It does now. The suite builds the editor sequenceEditor builds, in the
extension builder's registration order: InitialStateExtension's first
update included, and no registerCodeIndentation, since only
CodeIndentExtension registers it.

Two Rust differences from JS showed up, and both are fixed:

  • NormalizeInlineElementsExtension's registration (deleteEmptyInline,
    which RichTextExtension depends on) wasn't ported, so empty links and
    autolinks stayed. It is now register_normalize_inline_elements, behind
    the extension feature.
  • In that editor, JS's getDOMSelection returns null, so
    $extendSelectionForDeletion and modify stop after their model step.
    Rust kept measuring and moved the selection into nearby text. A new
    SelectionMovement::has_dom_selection() (default true) lets an app say
    there is no DOM selection.

Test plan

Before

$ cargo run -q --release -p lexical-conformance | grep -E 'sequences|Total'
| `property/sequences` | – | – | – | – | – | not implemented |
| **Total** | 488 | 488 | 0 | 0 | 0 | |

After

$ cargo run -q --release -p lexical-conformance | grep -E 'sequences|Total'
| `property/sequences` | 81 | 81 | 0 | 0 | 0 | pass |
| **Total** | 569 | 569 | 0 | 0 | 0 | |
$ cargo test --workspace --all-features
38 passed, 0 failed

Mutations, each restored afterwards: delete_empty_inline removing
nothing fails 19 cases; the early return in
extend_selection_for_deletion disabled fails 6; FORMAT_TEXT_COMMAND
formatting nothing fails 15. doctored_sequences_fail checks that a
vector with one handled and one text changed fails exactly those
steps.

cargo fmt --check, clippy -D warnings, rustdoc -D warnings,
cargo +1.88 check, --no-default-features and Rune's clippy pass.

Stacked on #146.

…nd JS's no-DOM-selection deletion

## Description

The Rust conformance runner didn't replay `property/sequences`, the 81
random command sequences JS records on a rich-text editor with lists,
check lists, links, hashtags, code and history.

It does now. The suite builds the editor `sequenceEditor` builds, in the
extension builder's registration order: `InitialStateExtension`'s first
update included, and no `registerCodeIndentation`, since only
`CodeIndentExtension` registers it.

Two Rust differences from JS showed up, and both are fixed:

- `NormalizeInlineElementsExtension`'s registration (`deleteEmptyInline`,
  which `RichTextExtension` depends on) wasn't ported, so empty links and
  autolinks stayed. It is now `register_normalize_inline_elements`, behind
  the `extension` feature.
- In that editor, JS's `getDOMSelection` returns null, so
  `$extendSelectionForDeletion` and `modify` stop after their model step.
  Rust kept measuring and moved the selection into nearby text. A new
  `SelectionMovement::has_dom_selection()` (default true) lets an app say
  there is no DOM selection.

## Test plan

### Before

```
$ cargo run -q --release -p lexical-conformance | grep -E 'sequences|Total'
| `property/sequences` | – | – | – | – | – | not implemented |
| **Total** | 488 | 488 | 0 | 0 | 0 | |
```

### After

```
$ cargo run -q --release -p lexical-conformance | grep -E 'sequences|Total'
| `property/sequences` | 81 | 81 | 0 | 0 | 0 | pass |
| **Total** | 569 | 569 | 0 | 0 | 0 | |
$ cargo test --workspace --all-features
38 passed, 0 failed
```

Mutations, each restored afterwards: `delete_empty_inline` removing
nothing fails 19 cases; the early return in
`extend_selection_for_deletion` disabled fails 6; `FORMAT_TEXT_COMMAND`
formatting nothing fails 15. `doctored_sequences_fail` checks that a
vector with one `handled` and one `text` changed fails exactly those
steps.

`cargo fmt --check`, clippy `-D warnings`, rustdoc `-D warnings`,
`cargo +1.88 check`, `--no-default-features` and Rune's clippy pass.

Amp-Thread-ID: https://ampcode.com/threads/T-16d45229-bfa8-417a-a091-d3e3888d830d

This branch has not been deployed

No deployments
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