From ce1b14d937e251c09e90c8ad74d2ecd864769b11 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 19 Jun 2014 07:38:00 +0000 Subject: Copy newline when at EOL in vi(1) mode, from Balazs Kezes. --- usr.bin/tmux/window-copy.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 85510368c87..0e0d1ee3bd1 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.110 2014/05/14 06:39:58 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.111 2014/06/19 07:37:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1360,7 +1360,7 @@ window_copy_get_selection(struct window_pane *wp, size_t *len) struct screen *s = &data->screen; char *buf; size_t off; - u_int i, xx, yy, sx, sy, ex, ey; + u_int i, xx, yy, sx, sy, ex, ey, ey_last; u_int firstsx, lastex, restex, restsx; int keys; @@ -1389,9 +1389,9 @@ window_copy_get_selection(struct window_pane *wp, size_t *len) } /* Trim ex to end of line. */ - xx = window_copy_find_length(wp, ey); - if (ex > xx) - ex = xx; + ey_last = window_copy_find_length(wp, ey); + if (ex > ey_last) + ex = ey_last; /* * Deal with rectangle-copy if necessary; four situations: start of @@ -1453,7 +1453,9 @@ window_copy_get_selection(struct window_pane *wp, size_t *len) free(buf); return (NULL); } - *len = off - 1; /* remove final \n */ + if (keys == MODEKEY_EMACS || lastex <= ey_last) + off -= 1; /* remove final \n (unless at end in vi mode) */ + *len = off; return (buf); } -- cgit v1.2.3