Skip to content

refactor: select clip editor via DataTemplates#188

Merged
fuzzzerd merged 1 commit intomasterfrom
fuzzz/avalonia12-editor-templates
Apr 23, 2026
Merged

refactor: select clip editor via DataTemplates#188
fuzzzerd merged 1 commit intomasterfrom
fuzzz/avalonia12-editor-templates

Conversation

@fuzzzerd
Copy link
Copy Markdown
Owner

Summary

Avalonia 12 logs binding warnings on null-pivot path chains. The previous editor region used IsVisible bindings on SelectedClip.IsScriptClip, SelectedClip.IsTableClip, and SelectedClip.IsFallbackClip, which all resolve through SelectedClip and produced six warnings at startup before any clip was selected.

Selection is now driven by nested ContentControls keyed on ClipViewModel.Editor's runtime type via DataTemplates. No editor instance exists when no clip is selected, so no binding chain resolves through null and the warnings are gone.

The script editor lives in a new ScriptTextEditor : TextEditor subclass that owns its TextMate.Installation and ScriptEditorController lifecycle and self-installs from its DataTemplate. StyleKeyOverride is set to typeof(TextEditor) because Avalonia 12 matches styles by exact type — without it the subclass renders blank. The fallback XML editor is inlined into its DataTemplate since it has no behavior beyond a Document binding.

Corresponding setup is dropped from MainWindow code-behind.

Test plan

  • dotnet build SharpFM.sln clean
  • dotnet test SharpFM.sln — 1,155 passing
  • Manual smoke test: startup (no binding warnings), script clip (TextMate highlighting, step margin, sealed steps), table clip, fallback clip, switching between editor types

Avalonia 12 logs binding warnings on null-pivot path chains. The
MainWindow editor region used IsVisible guards on SelectedClip.IsScriptClip,
SelectedClip.IsTableClip, etc., which all bind through SelectedClip and
spam warnings at startup before any clip is selected.

Replace the three sibling editors with nested ContentControls keyed on
ClipViewModel.Editor's runtime type. No editor instance exists when no
clip is selected, so no binding chain resolves through null.

Move the script editor's TextMate install and ScriptEditorController
ownership into a ScriptTextEditor subclass so it self-installs from the
DataTemplate. Override StyleKeyOverride to inherit TextEditor's control
template — Avalonia 12 matches styles by exact type, and without it the
subclass renders blank.

Drop the corresponding wiring from MainWindow code-behind.
@github-actions
Copy link
Copy Markdown

Test Results

✔️ Tests 1155 / 1155 - passed in 11.4s
✔️ Coverage 78.08% - passed with 70% threshold
📏 13104 / 15325 lines covered 🌿 4506 / 7229 branches covered
🔍 click here for more details

✏️ updated for commit c46a963

@fuzzzerd fuzzzerd merged commit c28c505 into master Apr 23, 2026
6 checks passed
@fuzzzerd fuzzzerd deleted the fuzzz/avalonia12-editor-templates branch April 23, 2026 22:50
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