From 44827fe53f447214489e4f05dd58bd8531813192 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Sat, 14 Feb 2026 23:05:44 -0800 Subject: [PATCH] Add mark-clearing behavior to refresh command and related test. - Updated `Refresh` command to clear the mark when no active prompt, search, or visual-line mode is present. - Added a new unit test verifying mark-clearing behavior for `Ctrl-G` (mapped to `Refresh`). - Bumped version to 1.6.3 in `CMakeLists.txt`. --- CMakeLists.txt | 2 +- Command.cc | 8 ++++++++ tests/test_command_semantics.cc | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1e2763..c4ff68f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(kte) include(GNUInstallDirs) set(CMAKE_CXX_STANDARD 20) -set(KTE_VERSION "1.6.2") +set(KTE_VERSION "1.6.3") # Default to terminal-only build to avoid SDL/OpenGL dependency by default. # Enable with -DBUILD_GUI=ON when SDL2/OpenGL/Freetype are available. diff --git a/Command.cc b/Command.cc index eb63538..89c694b 100644 --- a/Command.cc +++ b/Command.cc @@ -817,6 +817,14 @@ cmd_refresh(CommandContext &ctx) ctx.editor.SetStatus("Find canceled"); return true; } + // If nothing else to cancel, treat C-g/refresh as a mark clear (ke behavior). + if (Buffer *buf = ctx.editor.CurrentBuffer()) { + if (buf->MarkSet()) { + buf->ClearMark(); + ctx.editor.SetStatus("Mark cleared"); + return true; + } + } // Otherwise just a hint; renderer will redraw ctx.editor.SetStatus(""); return true; diff --git a/tests/test_command_semantics.cc b/tests/test_command_semantics.cc index 27d155b..e04d624 100644 --- a/tests/test_command_semantics.cc +++ b/tests/test_command_semantics.cc @@ -59,6 +59,25 @@ TEST (CommandSemantics_ToggleMark_JumpToMark) } +TEST (CommandSemantics_CtrlGRefresh_ClearsMark_WhenNothingElseToCancel) +{ + TestHarness h; + Buffer &b = h.Buf(); + + b.insert_text(0, 0, std::string("hello")); + b.SetCursor(2, 0); + ASSERT_EQ(b.MarkSet(), false); + + ASSERT_TRUE(h.Exec(CommandId::ToggleMark)); + ASSERT_EQ(b.MarkSet(), true); + + // C-g is mapped to Refresh; when there's no prompt/search/visual-line mode to cancel, + // it should clear the mark. + ASSERT_TRUE(h.Exec(CommandId::Refresh)); + ASSERT_EQ(b.MarkSet(), false); +} + + TEST (CommandSemantics_CopyRegion_And_KillRegion) { TestHarness h;