mirror of
https://github.com/tmux/tmux.git
synced 2026-06-20 17:25:57 +00:00
With mode-keys vi, keep cursor in the same position relative to the text
when scrolling. GitHub issue 5216 from Arseniy Simonov.
This commit is contained in:
@@ -6105,6 +6105,7 @@ static void
|
||||
window_copy_cursor_up(struct window_mode_entry *wme, int scroll_only)
|
||||
{
|
||||
struct window_copy_mode_data *data = wme->data;
|
||||
struct options *oo = wme->wp->window->options;
|
||||
struct screen *s = &data->screen;
|
||||
u_int ox, oy, px, py;
|
||||
int norectsel;
|
||||
@@ -6120,6 +6121,11 @@ window_copy_cursor_up(struct window_mode_entry *wme, int scroll_only)
|
||||
if (data->lineflag == LINE_SEL_LEFT_RIGHT && oy == data->sely)
|
||||
window_copy_other_end(wme);
|
||||
|
||||
if (scroll_only && options_get_number(oo, "mode-keys") == MODEKEY_VI) {
|
||||
if (data->cy < screen_size_y(s) - 1)
|
||||
window_copy_update_cursor(wme, data->cx, data->cy + 1);
|
||||
}
|
||||
|
||||
if (scroll_only || data->cy == 0) {
|
||||
if (norectsel)
|
||||
data->cx = data->lastcx;
|
||||
@@ -6179,6 +6185,7 @@ static void
|
||||
window_copy_cursor_down(struct window_mode_entry *wme, int scroll_only)
|
||||
{
|
||||
struct window_copy_mode_data *data = wme->data;
|
||||
struct options *oo = wme->wp->window->options;
|
||||
struct screen *s = &data->screen;
|
||||
u_int ox, oy, px, py;
|
||||
int norectsel;
|
||||
@@ -6194,6 +6201,11 @@ window_copy_cursor_down(struct window_mode_entry *wme, int scroll_only)
|
||||
if (data->lineflag == LINE_SEL_RIGHT_LEFT && oy == data->endsely)
|
||||
window_copy_other_end(wme);
|
||||
|
||||
if (scroll_only && options_get_number(oo, "mode-keys") == MODEKEY_VI) {
|
||||
if (data->cy > 0)
|
||||
window_copy_update_cursor(wme, data->cx, data->cy - 1);
|
||||
}
|
||||
|
||||
if (scroll_only || data->cy == screen_size_y(s) - 1) {
|
||||
if (norectsel)
|
||||
data->cx = data->lastcx;
|
||||
|
||||
Reference in New Issue
Block a user