diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-04-23 13:46:35 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-04-23 13:46:35 +0000 |
commit | 98bfe98e23cf77217c840f9b4d662c56823a3c85 (patch) | |
tree | 5845eab2de0bfff8e851b781d4da0189cbba6ec1 /usr.bin/tmux/window-copy.c | |
parent | 737f9173162b17c2b9f3c742dd8e58a1673aad0b (diff) |
Check whether cursor is at start or end when copying rectangular
selections, from tb@.
Diffstat (limited to 'usr.bin/tmux/window-copy.c')
-rw-r--r-- | usr.bin/tmux/window-copy.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 903298bba1f..07f067f13f1 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.187 2018/03/08 08:09:10 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.188 2018/04/23 13:46:34 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1548,7 +1548,7 @@ window_copy_get_selection(struct window_pane *wp, size_t *len) char *buf; size_t off; u_int i, xx, yy, sx, sy, ex, ey, ey_last; - u_int firstsx, lastex, restex, restsx; + u_int firstsx, lastex, restex, restsx, selx; int keys; if (!s->sel.flag && s->sel.lineflag == LINE_SEL_NONE) @@ -1599,7 +1599,11 @@ window_copy_get_selection(struct window_pane *wp, size_t *len) * Need to ignore the column with the cursor in it, which for * rectangular copy means knowing which side the cursor is on. */ - if (data->selx < data->cx) { + if (data->cursordrag == CURSORDRAG_ENDSEL) + selx = data->selx; + else + selx = data->endselx; + if (selx < data->cx) { /* Selection start is on the left. */ if (keys == MODEKEY_EMACS) { lastex = data->cx; @@ -1609,12 +1613,12 @@ window_copy_get_selection(struct window_pane *wp, size_t *len) lastex = data->cx + 1; restex = data->cx + 1; } - firstsx = data->selx; - restsx = data->selx; + firstsx = selx; + restsx = selx; } else { /* Cursor is on the left. */ - lastex = data->selx + 1; - restex = data->selx + 1; + lastex = selx + 1; + restex = selx + 1; firstsx = data->cx; restsx = data->cx; } |