From Prompt22. Design: Code Editor Implementations. Record: Milestone 14 - Implementation Log.
Scope
packages/editors/code-native—NativeCodeExtension(dev.moonkale.editor-code-native, opt-in): a panel per text document it claims,dioxus-code-editorinside, the same toolbar as CodeMirror’s (path, dirty dot, language, Save, Reload) plus the CodeMirror switch; language fromNode::language_hint→Language::from_slug; theme follows the app theme (CodeTheme::system); edits replaceDocument.text; Ctrl+S saves. Grammars: the core languages only (featureslang-*), notall-languages.- Claiming:
Workspace::editor_for(node) -> "codemirror" | "native"from the per-document choice (editor_choice), elseeditor.implementation, else whichever extension is enabled; both extensions filterdocumentsby it; the CodeMirror panel gets a Rust switch. Settings under both rows. - Cursor word:
Workspace::{cursor, set_cursor, cursor_word()}(line, col of the active document’s caret); the CodeMirror panel passes the column it already receives; the native panel readsselectionStarton caret-moving events.word_atunit-tested. - Rust terminal rows cut (P-112): re-measure on a timer + anchor to the bottom.
- Verify (E2E
code-native.mjs: enable, openmain.rsin Rust editor, highlighted spans, type + save, switch back to CodeMirror and forward;cursor_wordchecked through the status bar or a data attribute), log, vault, Extension Catalogue, JavaScript Inventory.
Decisions
- No modal chooser for editors (opening must be instant); the setting decides, the toolbar switches.
all-languagesoff: ~100 grammars would double compile time; the core list is enough and matches Core Languages.- The one JS touch in the Rust editor (reading
selectionStart) is Dioxus’s eval, not a bundle; documented in JavaScript Inventory.
Risks
| risk | mitigation |
|---|---|
dioxus-code-editor 0.1.x churns | pinned; the extension is 300 lines around it |
| big files in a textarea + full re-highlight per keystroke | the crate highlights incrementally; Case Selector still points big files at plain text |
| the textarea’s undo is lost on switching editors | stated in the docs; the document’s text is what carries over |