shithub: pplay

Download patch

ref: 0a2b6b19d93ae65bae4e78ee4d97a8753a08811c
parent: c5626b88e19926b1a768ae851aed751dc4b9a022
author: qwx <qwx@sciops.net>
date: Thu Feb 9 12:27:30 EST 2023

cmd: fix wrong offset for paste/replace

--- a/cmd.c
+++ b/cmd.c
@@ -107,17 +107,19 @@
 replace(char *, Chunk *c)
 {
 	Chunk *left, *latch;
+	usize n;
 
 	if(c == nil){
 		fprint(2, "replace: nothing to paste\n");
 		return -1;
 	}
+	n = chunklen(c);
 	if((left = inserton(dot.from, dot.to, c, &latch)) == nil){
 		fprint(2, "insert: %r\n");
 		return -1;
 	}
 	pushop(OPdel, dot.from, dot.to, latch);
-	pushop(OPins, dot.from, dot.to, nil);
+	pushop(OPins, dot.from, dot.from+n, nil);
 	setdot(&dot, nil);
 	dot.pos = c2p(left->right);
 	return 1;