Copy newline when at EOL in vi(1) mode, from Balazs Kezes.

This commit is contained in:
nicm 2014-06-19 07:37:59 +00:00
parent fd9a53b4a4
commit 00ac1af43f

View File

@ -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);
}