Skip to content

feat: add Command.InsertCaretAbove / .InsertCaretBelow (#5318)#5319

Merged
tig merged 2 commits into
developfrom
claude/command-insertcaret-5318
May 17, 2026
Merged

feat: add Command.InsertCaretAbove / .InsertCaretBelow (#5318)#5319
tig merged 2 commits into
developfrom
claude/command-insertcaret-5318

Conversation

@tig
Copy link
Copy Markdown
Member

@tig tig commented May 17, 2026

Summary

Adds two named Command members — InsertCaretAbove and InsertCaretBelow — mirroring VS Code's editor.action.insertCursorAbove / Below. Closes #5318.

Why

The configurable keybinding surface (Application.DefaultKeyBindings, View.DefaultKeyBindings, per-view DefaultKeyBindings, View.ViewKeyBindings, ApplyKeyBindings/ApplyLayer) is keyed by Command. A View that needs a command TG doesn't define has no sanctioned way to register it through that mechanism. Multi-caret editors — e.g. gui-cs/Editor's vertical multi-caret (gui-cs/Editor#133) — need add-caret-above/below; nothing in the enum fits, forcing (Command) 1001-style magic-int casts that don't round-trip through config.json by a readable name and risk collision if the enum is renumbered.

What

  • Command.InsertCaretAbove, Command.InsertCaretBelow, with XML docs, in a new #region Multi-Caret Commands.
  • Appended at the end of the enum so no existing member's implicit value changes — serialization-stable, no renumbering of persisted bindings.
  • No behavior change in TG itself: these are command ids for consumers to AddCommand + bind. TG core views don't bind them.

Scope / not in this PR

This intentionally does not introduce a general extensibility mechanism. A first-class API for extending the command set (string-keyed ids vs. a reserved-range registry; interaction with command bubbling/bridging, the binding layers, and ConfigurationManager name serialization) is a larger design tracked separately in #5319.

Test plan

  • Terminal.Gui core builds clean (0 errors; only the unrelated SourceLink "no upstream remote" note).
  • Reviewer confirms enum-tail placement is acceptable (no renumbering of existing members).
  • Consumer validation: gui-cs/Editor switches its (Command) 1001/1002 casts to these members once a TG release including them is consumed (gui-cs/Editor specs/decisions.md DEC-006).

Refs: #5318. Related: #4888 (configurable MouseBindings), gui-cs/Editor#133.

🤖 Generated with Claude Code

The configurable keybinding surface (Application/View DefaultKeyBindings,
ViewKeyBindings, ApplyKeyBindings) is keyed by Command, so a View that
needs a command the enum doesn't define has no sanctioned way to register
it. Multi-caret editors (e.g. gui-cs/Editor's vertical multi-caret) need
"add caret above/below"; nothing in the enum fits, forcing magic-int
casts that don't round-trip through config by name.

Adds two named members mirroring VS Code's editor.action.insertCursor
Above / Below. Appended at the END of the enum so no existing member's
implicit value changes (serialization-stable; no renumbering).

No behavior change in TG itself — these are command ids for consumers to
AddCommand + bind. A general Command-extensibility API (string ids /
registry, bubbling/bridging) is tracked separately.

Refs: #5318. Related: #4888.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
#5319 shipped the two enum members with no tests. Add coverage for the
parts of the contract that matter:

- CommandInsertCaretEnumTests: members are defined, distinct, carry their
  readable names, and are appended at the END of the enum (no existing
  member renumbered) — the property that keeps persisted configs stable.
- CommandInsertCaretKeyBindingTests: the #5318 acceptance criterion —
  Dictionary<Command, PlatformKeyBinding> round-trips through the config
  serializer (SourceGenerationContext) BY READABLE NAME, deserializes
  from the hand-written user-config form, and works nested under a
  per-view [ConfigurationProperty] dict ("Editor" → bindings) — exactly
  the gui-cs/Editor scenario the magic-int cast broke.

All 9 new tests green in UnitTests.Parallelizable. Mirrors the existing
KeyBindingSchemaTests style and uses the same canonical JSON options.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tig tig merged commit 62aa655 into develop May 17, 2026
13 checks passed
@tig tig deleted the claude/command-insertcaret-5318 branch May 17, 2026 05:57
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.

Command enum: add multi-caret members InsertCaretAbove / InsertCaretBelow

1 participant