=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- src/usr.bin/tmux/screen.c 2009/12/03 22:50:10 1.12 +++ src/usr.bin/tmux/screen.c 2010/01/03 17:12:04 1.13 @@ -1,4 +1,4 @@ -/* $OpenBSD: screen.c,v 1.12 2009/12/03 22:50:10 nicm Exp $ */ +/* $OpenBSD: screen.c,v 1.13 2010/01/03 17:12:04 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -234,11 +234,31 @@ struct screen_sel *sel = &s->sel; memcpy(&sel->cell, gc, sizeof sel->cell); - sel->flag = 1; - if (ey < sy || (sy == ey && ex < sx)) { + + /* starting line < ending line -- downward selection. */ + if (sy < ey) { + sel->sx = sx; sel->sy = sy; + sel->ex = ex; sel->ey = ey; + return; + } + + /* starting line > ending line -- upward selection. */ + if (sy > ey) { + if (sx > 0) { + sel->sx = ex; sel->sy = ey; + sel->ex = sx - 1; sel->ey = sy; + } else { + sel->sx = ex; sel->sy = ey; + sel->ex = -1; sel->ey = sy - 1; + } + return; + } + + /* starting line == ending line. */ + if (ex < sx) { sel->sx = ex; sel->sy = ey; - sel->ex = sx; sel->ey = sy; + sel->ex = sx - 1; sel->ey = sy; } else { sel->sx = sx; sel->sy = sy; sel->ex = ex; sel->ey = ey;