Skip to content

Web UI: ConfigEditorModal — preserve CodeMirror undo history and cursor across New/Revert/Save As #147

Open

Description

@falbany

Problem

The view effect depends on [open, load] (ConfigEditorModal.tsx:414-459), so any setLoad destroys and recreates the CodeMirror view: after New, Revert, and after Save As (markSaved, lines 738-761, whose anchorChanged branch deliberately bumps load). The comments already acknowledge the hazard ("the remount would rebuild the view…"), and plain Save works around it — but the Save-As/New/Revert remounts reset undo history, cursor and scroll position.

Suggested fix

Create the view once per open session and swap content via dispatch({ changes: { insert: text, from: 0, to: doc.length } }) (which also keeps a sensible undo entry), updating loadedTextRef/baselineHashRef as today.

Activity

  1. added
    code-quality
    frontend
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-qualityfrontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions