diff options
author | 2009-06-04 23:31:47 +0000 | |
---|---|---|
committer | 2009-06-04 23:31:47 +0000 | |
commit | 36b9bf57b880fd04c6aaae64c51f207e0a770ac3 (patch) | |
tree | 92b8067f756d7f74916e20b3a2501c1013041d18 | |
parent | When in auto-mode, automatically install binary files (from the X set). (diff) | |
download | wireguard-openbsd-36b9bf57b880fd04c6aaae64c51f207e0a770ac3.tar.xz wireguard-openbsd-36b9bf57b880fd04c6aaae64c51f207e0a770ac3.zip |
Fix problem where line numbers get out of sync on a region-kill (C-w).
Noticed and ok matthieu@
-rw-r--r-- | usr.bin/mg/def.h | 3 | ||||
-rw-r--r-- | usr.bin/mg/region.c | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h index 39e1859f7e9..2de0ef407c7 100644 --- a/usr.bin/mg/def.h +++ b/usr.bin/mg/def.h @@ -1,4 +1,4 @@ -/* $OpenBSD: def.h,v 1.109 2009/06/04 02:23:37 kjell Exp $ */ +/* $OpenBSD: def.h,v 1.110 2009/06/04 23:31:47 kjell Exp $ */ /* This file is in the public domain. */ @@ -117,6 +117,7 @@ typedef int (*PF)(int, int); /* generally useful type */ struct region { struct line *r_linep; /* Origin line address. */ int r_offset; /* Origin line offset. */ + int r_lineno; /* Origin line number */ RSIZE r_size; /* Length in characters. */ }; diff --git a/usr.bin/mg/region.c b/usr.bin/mg/region.c index 78555084453..3a554a47002 100644 --- a/usr.bin/mg/region.c +++ b/usr.bin/mg/region.c @@ -1,4 +1,4 @@ -/* $OpenBSD: region.c,v 1.27 2008/09/15 16:11:35 kjell Exp $ */ +/* $OpenBSD: region.c,v 1.28 2009/06/04 23:31:48 kjell Exp $ */ /* This file is in the public domain. */ @@ -33,6 +33,7 @@ killregion(int f, int n) thisflag |= CFKILL; curwp->w_dotp = region.r_linep; curwp->w_doto = region.r_offset; + curwp->w_dotline = region.r_lineno; s = ldelete(region.r_size, KFORW); clearmark(FFARG, 0); @@ -194,6 +195,7 @@ getregion(struct region *rp) /* "r_size" always ok */ if (curwp->w_dotp == curwp->w_markp) { rp->r_linep = curwp->w_dotp; + rp->r_lineno = curwp->w_dotline; if (curwp->w_doto < curwp->w_marko) { rp->r_offset = curwp->w_doto; rp->r_size = (RSIZE)(curwp->w_marko - curwp->w_doto); @@ -213,6 +215,7 @@ getregion(struct region *rp) if (flp == curwp->w_markp) { rp->r_linep = curwp->w_dotp; rp->r_offset = curwp->w_doto; + rp->r_lineno = curwp->w_dotline; return (setsize(rp, (RSIZE)(fsize + curwp->w_marko))); } @@ -224,6 +227,7 @@ getregion(struct region *rp) if (blp == curwp->w_markp) { rp->r_linep = blp; rp->r_offset = curwp->w_marko; + rp->r_lineno = curwp->w_markline; return (setsize(rp, (RSIZE)(bsize - curwp->w_marko))); } @@ -285,6 +289,7 @@ prefixregion(int f, int n) /* move to beginning of region */ curwp->w_dotp = region.r_linep; curwp->w_doto = region.r_offset; + curwp->w_dotline = region.r_lineno; /* for each line, go to beginning and insert the prefix string */ while (nline--) { |