From 20a2bca52e0d159cdbab4ff6d38024cd1503a4f5 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 27 Aug 2023 08:05:46 +1000 Subject: Do not make cursor visible after mouse scrolling and view commands ensure cursor is visible after user input except if the command implementation opted-out. Hooks and timers should not enforce visible cursor. PageUp/PageDown and `` / `` commands still move the cursor as this seemed a desired behaviour. --- src/normal.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/normal.cc') diff --git a/src/normal.cc b/src/normal.cc index 79a434ac..81caeb2d 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -368,6 +368,7 @@ void view_commands(Context& context, NormalParams params) const int count = params.count; on_next_key_with_autoinfo(context, "view", KeymapMode::View, [count](Key key, Context& context) { + context.ensure_cursor_visible = false; if (key == Key::Escape) return; @@ -400,10 +401,10 @@ void view_commands(Context& context, NormalParams params) window.scroll(-std::max(1, count)); break; case 'j': - scroll_window(context, std::max(1, count)); + scroll_window(context, std::max(1, count), OnHiddenCursor::PreserveSelections); break; case 'k': - scroll_window(context, -std::max(1, count)); + scroll_window(context, -std::max(1, count), OnHiddenCursor::PreserveSelections); break; case 'l': window.scroll( std::max(1, count)); @@ -1408,7 +1409,7 @@ void scroll(Context& context, NormalParams params) const int count = params.count ? params.count : 1; const LineCount offset = (window.dimensions().line - 2) / (half ? 2 : 1) * count; - scroll_window(context, offset * direction); + scroll_window(context, offset * direction, OnHiddenCursor::MoveCursorAndAnchor); } template -- cgit v1.2.3