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`.
This commit is contained in:
@@ -4,7 +4,7 @@ project(kte)
|
|||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
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.
|
# Default to terminal-only build to avoid SDL/OpenGL dependency by default.
|
||||||
# Enable with -DBUILD_GUI=ON when SDL2/OpenGL/Freetype are available.
|
# Enable with -DBUILD_GUI=ON when SDL2/OpenGL/Freetype are available.
|
||||||
|
|||||||
@@ -817,6 +817,14 @@ cmd_refresh(CommandContext &ctx)
|
|||||||
ctx.editor.SetStatus("Find canceled");
|
ctx.editor.SetStatus("Find canceled");
|
||||||
return true;
|
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
|
// Otherwise just a hint; renderer will redraw
|
||||||
ctx.editor.SetStatus("");
|
ctx.editor.SetStatus("");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -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)
|
TEST (CommandSemantics_CopyRegion_And_KillRegion)
|
||||||
{
|
{
|
||||||
TestHarness h;
|
TestHarness h;
|
||||||
|
|||||||
Reference in New Issue
Block a user