Editor: open scripts in an external editor

Stage-10 editor-UX follow-up, second half of in-editor script authoring:

- "✏ Edit" button on the Script inspector section (enabled once a
  source is assigned) and double-click on any script in the Project
  panel open the .rhai in the user's editor. Non-script assets
  double-click through xdg-open.
- Resolution order: the new External Editor preference command (spawned
  detached as `<command> <file>`, flags allowed), else $VISUAL/$EDITOR
  in a new Terminal-panel tab (TUI editors work in-editor via the
  existing PTY widget), else xdg-open.
- New `editor.external_editor` settings section (ExternalEditorPrefs)
  registered by EditorState, persisted with the preferences file, with
  a rich row in the Preferences window; registration covered by a unit
  test. Editor crate now depends on serde directly for its own
  sections.

Saved edits flow back through the file watcher's live reload, including
into a playing scene. GUI piece — needs an eye-check before promotion.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Homer
2026-07-10 20:41:37 +02:00
parent 4f1e9a48d7
commit d08bee1361
5 changed files with 212 additions and 13 deletions
+8
View File
@@ -214,6 +214,14 @@ Scripting plugs into the editor the same way physics does:
the undo stack — no round-trip through an external file manager. The template
is `oxide_editor::assets::script_template` (a unit test compiles it under the
sandboxed engine so it can never ship a syntax error).
- **Open in editor.** Next to New Script sits **✏ Edit** (enabled once a script
is assigned), and double-clicking a script in the **Project panel** does the
same: the file opens in your editor. Resolution order: the **External Editor**
command from Preferences (`editor.external_editor`, run as `<command> <file>`,
flags allowed — e.g. `code -g`); else `$VISUAL`/`$EDITOR` in a new
**Terminal-panel tab** (TUI editors work in-editor); else `xdg-open`. However
it opens, saving feeds the file watcher's live reload — including into a
playing scene. Double-clicking a non-script asset opens it via `xdg-open`.
- **Play loop.** When Play starts, the editor's play `App` adds `ScriptModule`
alongside `PhysicsModule`, **shares the editor's `AssetServer`**, and is handed
a snapshot of the project `AssetDatabase`. Sharing the server is what lets the