Commit Diff


commit - 9fdc52c625d7d82939d15db498352e7b5a9dede0
commit + aba09191af8012bc7d6a1b998ac937875f728d0c
blob - 7177127d3906c197f1dfa00cbd0ba325d9ffda36
blob + aa58be1a59e56db3bdfc2e99a97be7386c4a7a38
--- src/cmd/acme/text.c
+++ src/cmd/acme/text.c
@@ -862,7 +862,7 @@ textselect(Text *t)
 {
 	uint q0, q1;
 	int b, x, y;
-	int state;
+	int state, op;
 
 	selecttext = t;
 	/*
@@ -918,12 +918,12 @@ textselect(Text *t)
 		clicktext = nil;
 	textsetselect(t, q0, q1);
 	flushimage(display, 1);
-	state = 0;	/* undo when possible; +1 for cut, -1 for paste */
+	state = op = 0;	/* undo when possible; +1 for cut, -1 for paste */
 	while(mouse->buttons){
 		mouse->msec = 0;
 		b = mouse->buttons;
 		if(b & 6){
-			if(state==0 && t->what==Body){
+			if(state==0 && op==0 && t->what==Body){
 				seq++;
 				filemark(t->w->body.file);
 			}
@@ -932,18 +932,18 @@ textselect(Text *t)
 					winundo(t->w, TRUE);
 					textsetselect(t, q0, t->q0);
 					state = 0;
-				}else if(state != 1){
+				}else if(state != 1 && op != -1){
 					cut(t, t, nil, TRUE, TRUE, nil, 0);
-					state = 1;
+					op = state = 1;
 				}
 			}else{
 				if(state==1 && t->what==Body){
 					winundo(t->w, TRUE);
 					textsetselect(t, q0, t->q1);
 					state = 0;
-				}else if(state != -1){
+				}else if(state != -1 && op != 1){
 					paste(t, t, nil, TRUE, FALSE, nil, 0);
-					state = -1;
+					op = state = -1;
 				}
 			}
 			textscrdraw(t);