diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-28 12:33:53 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-28 12:33:53 +0000 |
commit | cd5370b6ec68b4d85c77ba44ea71df1bc8f2ac2e (patch) | |
tree | 9e9950b700622323833212c84a74b5466be44b0b /usr.bin | |
parent | 73cc66b2c760a2ba2688f6b95ad26bf7fbd9d34c (diff) |
sync
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/vi/vi/v_delete.c | 10 | ||||
-rw-r--r-- | usr.bin/vi/vi/v_yank.c | 32 |
2 files changed, 33 insertions, 9 deletions
diff --git a/usr.bin/vi/vi/v_delete.c b/usr.bin/vi/vi/v_delete.c index 56e3c9f709d..de1f47c4606 100644 --- a/usr.bin/vi/vi/v_delete.c +++ b/usr.bin/vi/vi/v_delete.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)v_delete.c 10.7 (Berkeley) 5/18/96"; +static const char sccsid[] = "@(#)v_delete.c 10.8 (Berkeley) 5/19/96"; #endif /* not lint */ #include <sys/types.h> @@ -79,9 +79,11 @@ v_delete(sp, vp) /* * !!! - * Cursor movements, other than those caused by a line mode - * command moving to another line, historically reset the - * relative position. + * Cursor movements, other than those caused by a line mode command + * moving to another line, historically reset the relative position. + * + * This currently matches the check made in v_yank(), I'm hoping that + * they should be consistent... */ if (!F_ISSET(vp, VM_LMODE)) { F_CLR(vp, VM_RCM_MASK); diff --git a/usr.bin/vi/vi/v_yank.c b/usr.bin/vi/vi/v_yank.c index 22a33ad403b..4708f199677 100644 --- a/usr.bin/vi/vi/v_yank.c +++ b/usr.bin/vi/vi/v_yank.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)v_yank.c 10.8 (Berkeley) 5/18/96"; +static const char sccsid[] = "@(#)v_yank.c 10.9 (Berkeley) 5/19/96"; #endif /* not lint */ #include <sys/types.h> @@ -46,15 +46,37 @@ v_yank(sp, vp) SCR *sp; VICMD *vp; { + size_t len; + if (cut(sp, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, &vp->m_start, &vp->m_stop, F_ISSET(vp, VM_LMODE) ? CUT_LINEMODE : 0)) return (1); + sp->rptlines[L_YANKED] += (vp->m_stop.lno - vp->m_start.lno) + 1; - /* Cursor movements reset the relative cursor position. */ - F_CLR(vp, VM_RCM_MASK); - F_SET(vp, VM_RCM_SET); + /* + * One special correction, in case we've deleted the current line or + * character. We check it here instead of checking in every command + * that can be a motion component. + */ + if (db_get(sp, vp->m_final.lno, DBG_FATAL, NULL, &len)) + return (1); - sp->rptlines[L_YANKED] += (vp->m_stop.lno - vp->m_start.lno) + 1; + /* + * !!! + * Cursor movements, other than those caused by a line mode command + * moving to another line, historically reset the relative position. + * + * This currently matches the check made in v_delete(), I'm hoping + * that they should be consistent... + */ + if (!F_ISSET(vp, VM_LMODE)) { + F_CLR(vp, VM_RCM_MASK); + F_SET(vp, VM_RCM_SET); + + /* Make sure the set cursor position exists. */ + if (vp->m_final.cno >= len) + vp->m_final.cno = len ? len - 1 : 0; + } return (0); } |