From ff10bb0be93d454d54b1f0d432ca57d3ae079e82 Mon Sep 17 00:00:00 2001 From: MultisampledNight Date: Fri, 8 Jul 2022 22:19:07 +0200 Subject: [PATCH] Fix #1207 The original check of whether a cursor movement was intentional or just in the same window wasn't enough for the command line, where a cursor didn't really move but was just displayed in the command line area for a short time. Hardcodes 4 as constant for the commandline mode, I have no idea how future-safe that is. --- src/editor/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/editor/mod.rs b/src/editor/mod.rs index e75cce8..a10b3c2 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -22,6 +22,8 @@ pub use grid::CharacterGrid; pub use style::{Colors, Style}; pub use window::*; +const MODE_CMDLINE: u64 = 4; + #[derive(Clone, Debug)] pub struct AnchorInfo { pub anchor_grid_id: u64, @@ -383,8 +385,14 @@ impl Editor { let intentional = grid_left == 1; // If the cursor was already in this message, we can still move within it. let already_there = self.cursor.parent_window_id == grid; - - if !intentional && !already_there { + // This ^ check alone is a bit buggy though, since it fails when the cursor is + // technically still in the edit window but "temporarily" at the cmdline. (#1207) + let using_cmdline = self + .current_mode_index + .map(|current| current == MODE_CMDLINE) + .unwrap_or(false); + + if !intentional && !already_there && !using_cmdline { trace!( "Cursor unexpectedly sent to message buffer {} ({}, {})", grid,