fix selection changing start on mode change

This commit is contained in:
Piotr Kocia 2025-06-17 14:50:20 +02:00
parent fa2b08846b
commit 6e38cb683a
2 changed files with 9 additions and 7 deletions

View file

@ -47,8 +47,10 @@ cmd_scrollback_up(struct terminal *term, int rows)
view, new_view, offset, grid_rows);
selection_view_up(term, new_view);
const int delta =
(term->grid->view - new_view) & (term->grid->num_rows - 1);
term->grid->view = new_view;
vimode_view_up(term, 0);
vimode_view_up(term, delta);
if (rows < term->rows) {
term_damage_scroll(
@ -102,8 +104,10 @@ cmd_scrollback_down(struct terminal *term, int rows)
view, new_view, offset, grid_rows);
selection_view_down(term, new_view);
const int delta =
(new_view - term->grid->view) & (term->grid->num_rows - 1);
term->grid->view = new_view;
vimode_view_down(term, 0);
vimode_view_down(term, delta);
if (rows < term->rows) {
term_damage_scroll(

View file

@ -458,17 +458,16 @@ void vimode_cancel(struct terminal *term)
render_refresh(term);
}
void vimode_view_up(struct terminal *term, int const delta)
void vimode_view_up(struct terminal *const term, int const delta)
{
if (!term->vimode.active) {
return;
}
damage_cursor_cell(term);
term->vimode.cursor.row += delta;
clip_cursor_to_view(term);
update_selection(term);
update_highlights(term);
term->vimode.selection.start.row += delta;
}
void vimode_view_down(struct terminal *const term, int const delta)
@ -477,11 +476,10 @@ void vimode_view_down(struct terminal *const term, int const delta)
return;
}
damage_cursor_cell(term);
term->vimode.cursor.row -= delta;
clip_cursor_to_view(term);
update_selection(term);
update_highlights(term);
term->vimode.selection.start.row -= delta;
}
static ssize_t matches_cell(const struct terminal *term,