=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen.c,v retrieving revision 1.27 retrieving revision 1.28 diff -c -r1.27 -r1.28 *** src/usr.bin/tmux/screen.c 2014/01/09 14:05:55 1.27 --- src/usr.bin/tmux/screen.c 2014/08/11 22:18:16 1.28 *************** *** 1,4 **** ! /* $OpenBSD: screen.c,v 1.27 2014/01/09 14:05:55 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: screen.c,v 1.28 2014/08/11 22:18:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 276,281 **** --- 276,282 ---- screen_check_selection(struct screen *s, u_int px, u_int py) { struct screen_sel *sel = &s->sel; + u_int xx; if (!sel->flag) return (0); *************** *** 325,341 **** if (py < sel->sy || py > sel->ey) return (0); ! if ((py == sel->sy && px < sel->sx) ! || (py == sel->ey && px > sel->ex)) return (0); } else if (sel->sy > sel->ey) { /* starting line > ending line -- upward selection. */ if (py > sel->sy || py < sel->ey) return (0); ! if ((py == sel->sy && px >= sel->sx) ! || (py == sel->ey && px < sel->ex)) return (0); } else { /* starting line == ending line. */ if (py != sel->sy) --- 326,350 ---- if (py < sel->sy || py > sel->ey) return (0); ! if (py == sel->sy && px < sel->sx) ! return 0; ! ! if (py == sel->ey && px > sel->ex) return (0); } else if (sel->sy > sel->ey) { /* starting line > ending line -- upward selection. */ if (py > sel->sy || py < sel->ey) return (0); ! if (py == sel->ey && px < sel->ex) return (0); + + if (sel->modekeys == MODEKEY_EMACS) + xx = sel->sx - 1; + else + xx = sel->sx; + if (py == sel->sy && px > xx) + return (0); } else { /* starting line == ending line. */ if (py != sel->sy) *************** *** 343,349 **** if (sel->ex < sel->sx) { /* cursor (ex) is on the left */ ! if (px > sel->sx || px < sel->ex) return (0); } else { /* selection start (sx) is on the left */ --- 352,362 ---- if (sel->ex < sel->sx) { /* cursor (ex) is on the left */ ! if (sel->modekeys == MODEKEY_EMACS) ! xx = sel->sx - 1; ! else ! xx = sel->sx; ! if (px > xx || px < sel->ex) return (0); } else { /* selection start (sx) is on the left */