Don't try to page up with scroll-mode -u or copy-mode -u unless the mode was

successfully changed - if already in a different mode, it would corrupt the
mode data.
This commit is contained in:
Nicholas Marriott 2009-06-29 07:11:20 +00:00
parent 710393e388
commit 003e8e65f7
2 changed files with 10 additions and 6 deletions

View File

@ -44,13 +44,15 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
{ {
struct cmd_target_data *data = self->data; struct cmd_target_data *data = self->data;
struct winlink *wl; struct winlink *wl;
struct window_pane *wp;
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
return (-1); return (-1);
wp = wl->window->active;
window_pane_set_mode(wl->window->active, &window_copy_mode); window_pane_set_mode(wp, &window_copy_mode);
if (data->flags & CMD_UFLAG) if (wp->mode == &window_copy_mode && data->flags & CMD_UFLAG)
window_copy_pageup(wl->window->active); window_copy_pageup(wp);
return (0); return (0);
} }

View File

@ -60,13 +60,15 @@ cmd_scroll_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
{ {
struct cmd_target_data *data = self->data; struct cmd_target_data *data = self->data;
struct winlink *wl; struct winlink *wl;
struct window_pane *wp;
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
return (-1); return (-1);
wp = wl->window->active;
window_pane_set_mode(wl->window->active, &window_scroll_mode); window_pane_set_mode(wp, &window_scroll_mode);
if (data->flags & CMD_UFLAG) if (wp->mode == &window_scroll_mode && data->flags & CMD_UFLAG)
window_scroll_pageup(wl->window->active); window_scroll_pageup(wp);
return (0); return (0);
} }