=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.408 retrieving revision 1.409 diff -c -r1.408 -r1.409 *** src/usr.bin/tmux/tty.c 2021/10/25 09:22:17 1.408 --- src/usr.bin/tmux/tty.c 2021/10/28 18:57:06 1.409 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.408 2021/10/25 09:22:17 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.409 2021/10/28 18:57:06 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 2278,2294 **** if (tty->flags & TTY_BLOCK) return; - if (cx > tty->sx - 1) - cx = tty->sx - 1; - thisx = tty->cx; thisy = tty->cy; /* No change. */ if (cx == thisx && cy == thisy) return; ! /* Very end of the line, just use absolute movement. */ if (thisx > tty->sx - 1) goto absolute; --- 2278,2302 ---- if (tty->flags & TTY_BLOCK) return; thisx = tty->cx; thisy = tty->cy; + /* + * If in the automargin space, and want to be there, do not move. + * Otherwise, force the cursor to be in range (and complain). + */ + if (cx == thisx && cy == thisy && cx == tty->sx) + return; + if (cx > tty->sx - 1) { + log_debug("%s: x too big %u > %u", __func__, cx, tty->sx - 1); + cx = tty->sx - 1; + } + /* No change. */ if (cx == thisx && cy == thisy) return; ! /* Currently at the very end of the line - use absolute movement. */ if (thisx > tty->sx - 1) goto absolute;