Tags: boldsoftware/shelley
Tags
shelley: fix diff viewer backspace/arrow keys deleting multiple chars Prompt: sometimes, when I use shelley, and i'm trying to edit code in the monaco diff view, clicking backspace removes multiple characters. arrow keys go multiple steps. Something's borked. See if you can repro and fix. In the diff viewer, after switching files or diffs a few times, pressing Backspace would delete several characters at once and arrow keys would jump multiple columns per press. Each keystroke fired as many cursor commands as the number of diff editors ever created in the session. Root cause: monaco-editor 0.44 keeps references to every diff editor ever created via monaco.editor.getDiffEditors(); disposing an editor releases its DOM and its code editors but leaves global keybinding contributions (and the reference) behind. Every one of those stale keybinding contributions routes keystrokes to the currently focused editor, so N stale editors = N cursor commands per keypress. DiffViewer was recreating the entire monaco.editor.createDiffEditor on every file, commit-messages update, cwd change, and isMobile flip. Recreate is the leak source. Fix: create the diff editor once (keyed only on monacoLoaded) and swap models when the selected file or diff changes. Dispose the previous models after swapping so they don't accumulate. Apply mobile-dependent layout options via updateOptions on resize instead of rebuilding the editor. Move the event handlers that depended on per-file or per- viewport state (isHeadCommit, cwd, isMobile) behind refs so a single set of listeners can live for the editor's lifetime. Co-authored-by: Shelley <[email protected]>
PreviousNext