Skip to content

refactor(editor): share the repeated viewer and contribution helpers - #1327

Open
bobzhang wants to merge 1 commit into
mainfrom
simplify/structural-editor
Open

refactor(editor): share the repeated viewer and contribution helpers#1327
bobzhang wants to merge 1 commit into
mainfrom
simplify/structural-editor

Conversation

@bobzhang

@bobzhang bobzhang commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

This half needs a careful read. Every hunk here adds or removes something
SHARED, so correctness depends on code outside the hunk you are looking at. The
purely in-function rewrites this was mixed with have moved to a separate pull
request, so what is left is all shared-surface change.

What to check, hardest first:

  1. An extracted helper must be equivalent at every call site it replaced.
    The trap is a call site that passed a different argument, or read state at a
    different moment, than its neighbours.
  2. A merged or-pattern arm must have had identical bodies. Where the arms
    differed and the difference moved inside the arm, the fold buys less than it
    appears to.
  3. A reshaped loop must keep its iteration order and its early exits.

Scope: editor/. The largest pieces are the cursor-key registration pairs, the shared listener disposal sweep, the repeated Option ladders in the code editor widget, and the shared decode helpers in the remote protocol.

Verified on this branch alone

moon fmt --check, the native and JS workspace checks with --deny-warn, both
full test suites, and from editor/ moon check --target all --warn-list +73 --deny-warn plus moon test --target all, with no other part of the refactor
applied. No .mbti changed.


The refactor is split so each pull request asks one kind of question. Every file
appears in exactly one of them, each was verified on its own branch with no
other part applied, so they merge in any order.

easy to review needs a careful read
root #1330 this one (#1325)
desktop/ #1331 #1326
editor/ #1332 #1327
tests #1333 #1328

🤖 Generated with Claude Code

https://claude.ai/code/session_01JiBNGzCsZpN6e5Y4p9pXdn

@bobzhang

bobzhang commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

The two red moon (nightly, …) checks are pre-existing and not from this PR:

Cannot find import 'moonbitlang/core/strconv' in moonbit-community/rabbita/url@0.15.4

Nightly core dropped core/strconv and the pinned rabbita still imports it, so
both nightly jobs fail the same way on main. They are continue-on-error: true
and do not gate merging. Nothing here touches dependency pins.

Every stable gate passes: native, JS and wasm checks with --deny-warn, the
generated-interface check, the cram suite, desktop e2e, viz e2e,
browser-correctness, and the editor's stable jobs on Linux and macOS.

This is the half that needs a careful read: these hunks add or remove something
SHARED, so correctness depends on code outside the hunk you are looking at.

What to check, hardest first:
1. **An extracted helper must be equivalent at every call site it replaced.**
   The trap is a call site that passed a different argument, or read state at a
   different moment, than its neighbours.
2. **A merged or-pattern arm must have had identical bodies.**
3. **A reshaped loop must keep its iteration order and its early exits.**

The purely local rewrites these were mixed with have been split into a separate
pull request, so everything left here is shared-surface change.

Verified on this branch alone, with no other part of the refactor applied:
`moon fmt --check`, the native and JS workspace checks with `--deny-warn`, both
full test suites, and from `editor/` `moon check --target all --warn-list +73
--deny-warn` plus `moon test --target all`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JiBNGzCsZpN6e5Y4p9pXdn
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.

1 participant