Skip to content

Port Editor and ted settings to MEC#240

Open
tig wants to merge 4 commits into
developfrom
tig/mec-port
Open

Port Editor and ted settings to MEC#240
tig wants to merge 4 commits into
developfrom
tig/mec-port

Conversation

@tig
Copy link
Copy Markdown
Member

@tig tig commented May 25, 2026

Summary

Ports Editor/ted configuration to Terminal.Gui's MEC path and aligns with the split migration plan now documented upstream:

  • #5411: functional CM -> MEC migration with compatibility shims
  • #5416: later cleanup/removal of legacy CM internals

This PR updates Editor to consume the MEC-facing configuration flow (TuiConfigurationBuilder) and keeps Editor-side compatibility behavior where needed (legacy key/value migration and load tolerance for ted settings files).

What changed

  • Use TuiConfigurationBuilder directly in ted bootstrap (reflection fallback removed)
  • Keep Editor keybinding configuration on MEC path and preserve legacy Terminal.Gui.Editor.Editor.DefaultKeyBindings key support during migration
  • Harden legacy ted dotted-key parsing (TryParse + error logging instead of startup exceptions)
  • Strengthen persistence tests to assert values under the nested EditorSettings JSON section
  • Keep/save migration behavior for legacy config shapes

Dependency/rollout plan

  • This PR is intended to land with/after #5411 availability (API surface from #5411 is required)
  • It is not blocked on #5416 semantics, but #5416 remains the upstream follow-up for legacy CM removal/size cleanup

CI note

Current Editor CI uses the published Terminal.Gui package line. Until a package containing #5411's TuiConfigurationBuilder is available to CI, hosted checks fail with missing-type errors; local verification against a package built from latest #5411 succeeds.

Local validation used for this branch state

  • Build Editor against a local package built from latest Terminal.Gui #5411 head
  • Run Editor unit/integration/config suites
  • Run targeted ted persistence + legacy keybinding coverage
  • Run upstream TG MEC CR-focused tests (MecCrFeedbackTests, MecDottedKeyTests) on latest #5411 head

Add MEC-backed Editor settings and keybinding parsing, move ted startup and persistence to the new nested configuration shape, and keep CM compatibility for released Terminal.Gui builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7aeefb7fc1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/ted/TerminalGuiConfigurationBootstrap.cs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports the Editor’s default keybinding configuration and ted’s persisted settings from Terminal.Gui’s legacy ConfigurationManager (CM) shape to a Microsoft.Extensions.Configuration (MEC) shape, while keeping CM compatibility for released Terminal.Gui versions.

Changes:

  • Introduces MEC-facing Terminal.Gui.Editor.Configuration.EditorSettings + EditorConfiguration to apply Editor:DefaultKeyBindings into Editor.DefaultKeyBindings.
  • Updates ted startup and persistence to read/write a nested "EditorSettings": { ... } section, while still accepting legacy flat (EditorSettings.*) and legacy CM (AppSettings dotted keys) inputs.
  • Updates unit/integration/config tests and project references to cover MEC application and legacy compatibility paths.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/Terminal.Gui.Editor.Tests/Terminal.Gui.Editor.Tests.csproj Adds MEC configuration package dependency for new config-driven tests.
tests/Terminal.Gui.Editor.Tests/EditorKeyBindingConfigTests.cs Switches from CM runtime config to MEC in-memory configuration for default keybinding overrides.
tests/Terminal.Gui.Editor.IntegrationTests/Terminal.Gui.Editor.IntegrationTests.csproj Adds MEC configuration package dependency for integration tests.
tests/Terminal.Gui.Editor.IntegrationTests/TedSettingsPersistenceTests.cs Updates persistence expectations to the nested MEC "EditorSettings" JSON shape and adds MEC/legacy load tests.
tests/Terminal.Gui.Editor.IntegrationTests/EditorKeyBindingIntegrationTests.cs Switches integration test coverage from CM to MEC for keybinding overrides.
tests/Terminal.Gui.Editor.ConfigTests/TedConfigurationManagerTests.cs Keeps CM end-to-end test, but resets via new EditorSettings.ResetDefaults().
src/Terminal.Gui.Editor/Terminal.Gui.Editor.csproj Adds Microsoft.Extensions.Configuration.Abstractions to support MEC-based configuration application.
src/Terminal.Gui.Editor/Editor.Commands.cs Routes Editor.DefaultKeyBindings through the new EditorSettings.Defaults facade.
src/Terminal.Gui.Editor/Configuration/EditorSettings.cs Adds MEC-friendly POCO + static Defaults holder for editor defaults.
src/Terminal.Gui.Editor/Configuration/EditorKeyBindingDefaults.cs Extracts the editor keybinding default table into a dedicated factory.
src/Terminal.Gui.Editor/Configuration/EditorConfiguration.cs Adds MEC reader/applicator to populate EditorSettings.Defaults.DefaultKeyBindings.
examples/ted/TerminalGuiConfigurationBootstrap.cs Adds MEC-first startup bootstrap with reflection-based detection + CM fallback.
examples/ted/ted.csproj Adds MEC Binder/Json packages needed for ted settings binding and JSON config loading.
examples/ted/Program.cs Replaces direct CM enablement with the new MEC/CM bootstrapper.
examples/ted/EditorSettings.cs Migrates ted settings read/write to nested "EditorSettings" section with legacy dotted-key migration support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/ted/TerminalGuiConfigurationBootstrap.cs Outdated
Comment thread examples/ted/EditorSettings.cs
Comment thread src/Terminal.Gui.Editor/Configuration/EditorKeyBindingDefaults.cs Outdated
Comment thread tests/Terminal.Gui.Editor.IntegrationTests/TedSettingsPersistenceTests.cs Outdated
Comment thread tests/Terminal.Gui.Editor.IntegrationTests/TedSettingsPersistenceTests.cs Outdated
Comment thread tests/Terminal.Gui.Editor.IntegrationTests/TedSettingsPersistenceTests.cs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 879a849b06

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Terminal.Gui.Editor/Configuration/EditorConfiguration.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcd2e01b83

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/ted/EditorSettings.cs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 08760144ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +45 to +47
if (!Enum.TryParse (commandSection.Key, true, out Command command))
{
throw new FormatException ($"Unknown editor command in configuration: '{commandSection.Key}'.");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle invalid keybinding entries without aborting startup

EditorConfiguration.Apply throws FormatException for unknown command names (and similarly for invalid key strings), and Program calls this during startup without catching it. A single stale/typoed keybinding in user config (for example after command renames across versions) will therefore terminate app startup instead of ignoring/logging that entry and continuing with defaults, which is a user-facing regression from tolerant config loading.

Useful? React with 👍 / 👎.

Comment on lines +140 to +151
root[SectionName] = new JsonObject
{
[nameof (LineNumbers)] = LineNumbers,
[nameof (FoldIndicators)] = FoldIndicators,
[nameof (WordWrap)] = WordWrap,
[nameof (ShowTabs)] = ShowTabs,
[nameof (IndentSize)] = IndentSize,
[nameof (ConvertTabsToSpaces)] = ConvertTabsToSpaces,
[nameof (AutoIndent)] = AutoIndent,
[nameof (AutoComplete)] = AutoComplete,
[nameof (Scrollbars)] = Scrollbars
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve unknown keys when rewriting EditorSettings section

Saving settings now replaces the entire EditorSettings object, so any unrecognized keys already present under that section (for example settings written by a newer ted version or another tool) are silently deleted on the next save. The previous save path updated known keys in place and preserved unrelated configuration, so this introduces avoidable config data loss during normal use.

Useful? React with 👍 / 👎.

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.

2 participants