Skip to content

Conversation

@Malandril
Copy link

Fixes #1139 , the lines the vi cursor was moving to were not to be updated.

@Malandril Malandril force-pushed the vim_fix_cursor branch 4 times, most recently from 093dd6e to 8e861f1 Compare July 15, 2025 13:51
@raphamorim
Copy link
Owner

Hey @Malandril thanks for the PR! Will take a look this week 🙏

diff --git c/frontends/rioterm/src/screen/mod.rs i/frontends/rioterm/src/screen/mod.rs
index b34626d..a3a32dd 100644
--- c/frontends/rioterm/src/screen/mod.rs
+++ i/frontends/rioterm/src/screen/mod.rs
@@ -1344,7 +1344,13 @@ impl Screen<'_> {
     pub fn clear_selection(&mut self) {
         // Clear the selection on the terminal.
         let mut terminal = self.context_manager.current_mut().terminal.lock();
-        terminal.selection.take();
+        let old_selection = terminal
+            .selection
+            .take()
+            .and_then(|s| s.to_range(&terminal));
+        let display_offset = terminal.display_offset();
+        let num_cols = terminal.grid.columns();
+        terminal.update_selection_damage(old_selection, display_offset, num_cols);
         drop(terminal);
         self.context_manager.current_mut().set_selection(None);
     }
diff --git c/rio-backend/src/crosswords/mod.rs i/rio-backend/src/crosswords/mod.rs
index 45e5ee9..4bb835f766 100644
--- c/rio-backend/src/crosswords/mod.rs
+++ i/rio-backend/src/crosswords/mod.rs
@@ -539,6 +539,10 @@ impl<U: EventListener> Crosswords<U> {
         let previous_cursor =
             mem::replace(&mut self.damage.last_cursor, self.grid.cursor.pos);

+        let previous_vim_cursor = mem::replace(
+            &mut self.damage.last_vi_cursor_point,
+            Some(self.vi_mode_cursor.pos),
+        );
         if self.damage.full {
             return TermDamage::Full;
         }
@@ -550,6 +554,14 @@ impl<U: EventListener> Crosswords<U> {
             let previous_line = previous_cursor.row.0 as usize;
             self.damage.damage_line(previous_line);
         }
+        if let (Some(prev_cursor), Some(curr_cursor)) =
+            (previous_vim_cursor, self.damage.last_vi_cursor_point)
+        {
+            if prev_cursor != curr_cursor {
+                let point = Pos::new(prev_cursor.row.0 as usize, prev_cursor.col);
+                self.damage.damage_point(point);
+            }
+        }

         // Always damage current cursor.
         self.damage_cursor();
@@ -887,6 +899,11 @@ impl<U: EventListener> Crosswords<U> {
     pub fn damage_cursor(&mut self) {
         // Use line-based damage approach for better reliability
         self.damage_cursor_line();
+                let vim_point = Pos::new(
+                    self.vi_mode_cursor.pos.row.0 as usize,
+                    self.vi_mode_cursor.pos.col,
+                );
+                self.damage.damage_point(vim_point);
     }

     #[inline]
@Katzenbiber
Copy link

Hello, thanks for the fix, it works for me. But I also noticed a regression: In neovim e.g. my line cursor is now a outlined rectangle. I assume something went wrong with the cursor style management

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VI cursor not visible

3 participants