Skip to content

Commit 108037c

Browse files
committed
fix: #1139 vi cursor not displayed when moving
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]
1 parent 3afc6ca commit 108037c

File tree

2 files changed

+24
-1
lines changed
  • frontends/rioterm/src/screen
  • rio-backend/src/crosswords

2 files changed

+24
-1
lines changed

frontends/rioterm/src/screen/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,12 @@ impl Screen<'_> {
13441344
pub fn clear_selection(&mut self) {
13451345
// Clear the selection on the terminal.
13461346
let mut terminal = self.context_manager.current_mut().terminal.lock();
1347-
terminal.selection.take();
1347+
let old_selection = terminal
1348+
.selection
1349+
.take()
1350+
.and_then(|s| s.to_range(&terminal));
1351+
let display_offset = terminal.display_offset();
1352+
terminal.update_selection_damage(old_selection, display_offset);
13481353
drop(terminal);
13491354
self.context_manager.current_mut().set_selection(None);
13501355
}

rio-backend/src/crosswords/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,10 @@ impl<U: EventListener> Crosswords<U> {
539539
let previous_cursor =
540540
mem::replace(&mut self.damage.last_cursor, self.grid.cursor.pos);
541541

542+
let previous_vim_cursor = mem::replace(
543+
&mut self.damage.last_vi_cursor_point,
544+
Some(self.vi_mode_cursor.pos),
545+
);
542546
if self.damage.full {
543547
return TermDamage::Full;
544548
}
@@ -550,6 +554,13 @@ impl<U: EventListener> Crosswords<U> {
550554
let previous_line = previous_cursor.row.0 as usize;
551555
self.damage.damage_line(previous_line);
552556
}
557+
if let (Some(prev_cursor), Some(curr_cursor)) =
558+
(previous_vim_cursor, self.damage.last_vi_cursor_point)
559+
{
560+
if prev_cursor != curr_cursor {
561+
self.damage.damage_line(prev_cursor.row.0 as usize);
562+
}
563+
}
553564

554565
// Always damage current cursor.
555566
self.damage_cursor();
@@ -877,6 +888,12 @@ impl<U: EventListener> Crosswords<U> {
877888
self.damage_line(cursor_line);
878889
}
879890

891+
#[inline]
892+
pub fn damage_vi_cursor_line(&mut self) {
893+
let vi_cursor_line = self.vi_mode_cursor.pos.row.0 as usize;
894+
self.damage.damage_line(vi_cursor_line);
895+
}
896+
880897
/// Damage an entire line
881898
#[inline]
882899
pub fn damage_line(&mut self, line: usize) {
@@ -887,6 +904,7 @@ impl<U: EventListener> Crosswords<U> {
887904
pub fn damage_cursor(&mut self) {
888905
// Use line-based damage approach for better reliability
889906
self.damage_cursor_line();
907+
self.damage_vi_cursor_line();
890908
}
891909

892910
#[inline]

0 commit comments

Comments
 (0)