feat: add Command.InsertCaretAbove / .InsertCaretBelow (#5318)#5319
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two named
Commandmembers —InsertCaretAboveandInsertCaretBelow— mirroring VS Code'seditor.action.insertCursorAbove/Below. Closes #5318.Why
The configurable keybinding surface (
Application.DefaultKeyBindings,View.DefaultKeyBindings, per-viewDefaultKeyBindings,View.ViewKeyBindings,ApplyKeyBindings/ApplyLayer) is keyed byCommand. AViewthat 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 throughconfig.jsonby 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.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
ConfigurationManagername serialization) is a larger design tracked separately in #5319.Test plan
Terminal.Guicore builds clean (0 errors; only the unrelated SourceLink "noupstreamremote" note).gui-cs/Editorswitches its(Command) 1001/1002casts to these members once a TG release including them is consumed (gui-cs/Editorspecs/decisions.mdDEC-006).Refs: #5318. Related: #4888 (configurable
MouseBindings), gui-cs/Editor#133.🤖 Generated with Claude Code