From d1cee52d6f3b7522f4a9288426540abbdb1dd055 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 May 2026 02:48:15 +0000 Subject: [PATCH 1/2] Initial plan From 5d626397b222fc570ce333d5f61e1be513767293 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 May 2026 02:50:39 +0000 Subject: [PATCH 2/2] fix: Esc clears primary selection when dismissing column block (multi-caret) The Esc handler called ClearAdditionalCarets() but never cleared the primary row's selection, leaving it highlighted and type-replaceable. Now calls ClearSelection() immediately after, matching the documented "collapse back to the primary caret" behavior. Fixes gui-cs/Editor#143 Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/9ff74825-e83a-4e36-9a03-dd9317677001 Co-authored-by: tig <585482+tig@users.noreply.github.com> --- src/Terminal.Gui.Editor/Editor.Keyboard.cs | 1 + .../EditorColumnSelectionTests.cs | 1 + .../__snapshots__/Keyboard_Column_Then_Esc_Collapses_Carets.ans | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Terminal.Gui.Editor/Editor.Keyboard.cs b/src/Terminal.Gui.Editor/Editor.Keyboard.cs index e6fbaaca..109f1b7b 100644 --- a/src/Terminal.Gui.Editor/Editor.Keyboard.cs +++ b/src/Terminal.Gui.Editor/Editor.Keyboard.cs @@ -60,6 +60,7 @@ protected override bool OnKeyDownNotHandled (Key key) if (key == Application.GetDefaultKey (Command.Quit) && HasMultipleCarets) { ClearAdditionalCarets (); + ClearSelection (); return true; } diff --git a/tests/Terminal.Gui.Editor.IntegrationTests/EditorColumnSelectionTests.cs b/tests/Terminal.Gui.Editor.IntegrationTests/EditorColumnSelectionTests.cs index 9488d678..c9961c30 100644 --- a/tests/Terminal.Gui.Editor.IntegrationTests/EditorColumnSelectionTests.cs +++ b/tests/Terminal.Gui.Editor.IntegrationTests/EditorColumnSelectionTests.cs @@ -207,6 +207,7 @@ public async Task Keyboard_Column_Then_Esc_Collapses_Carets () fx.Render (); Assert.False (fx.Top.Editor.HasMultipleCarets); + Assert.False (fx.Top.Editor.HasSelection); AnsiSnapshot.Verify (fx.Driver, nameof (Keyboard_Column_Then_Esc_Collapses_Carets)); } diff --git a/tests/Terminal.Gui.Editor.IntegrationTests/__snapshots__/Keyboard_Column_Then_Esc_Collapses_Carets.ans b/tests/Terminal.Gui.Editor.IntegrationTests/__snapshots__/Keyboard_Column_Then_Esc_Collapses_Carets.ans index 38786a61..98fc0f51 100644 --- a/tests/Terminal.Gui.Editor.IntegrationTests/__snapshots__/Keyboard_Column_Then_Esc_Collapses_Carets.ans +++ b/tests/Terminal.Gui.Editor.IntegrationTests/__snapshots__/Keyboard_Column_Then_Esc_Collapses_Carets.ans @@ -1,4 +1,4 @@ -abcd +abcd abcd abcd