about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--edit.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/edit.c b/edit.c
index 1f8f170..997feed 100644
--- a/edit.c
+++ b/edit.c
@@ -60,9 +60,9 @@ static bool reserve(size_t index, size_t count) {
 	return true;
 }
 
-static void delete(size_t index, size_t count) {
+static void delete(bool copy, size_t index, size_t count) {
 	if (index + count > len) return;
-	if (count > 1) {
+	if (copy) {
 		memcpy(cut.buf, &buf[index], sizeof(*buf) * count);
 		cut.len = count;
 	}
@@ -109,7 +109,7 @@ static void tabComplete(size_t id) {
 		return;
 	}
 
-	delete(tab.pos, tab.len);
+	delete(false, tab.pos, tab.len);
 	if (wcs[0] != L'/' && !tab.pos) {
 		tab.len = n + 2;
 		reserve(tab.pos, tab.len);
@@ -158,22 +158,22 @@ void edit(size_t id, enum Edit op, wchar_t ch) {
 			while (pos < len && !iswspace(buf[pos])) pos++;
 		}
 
-		break; case EditDeleteHead: delete(0, pos); pos = 0;
-		break; case EditDeleteTail: delete(pos, len - pos);
-		break; case EditDeletePrev: if (pos) delete(--pos, 1);
-		break; case EditDeleteNext: delete(pos, 1);
+		break; case EditDeleteHead: delete(true, 0, pos); pos = 0;
+		break; case EditDeleteTail: delete(true, pos, len - pos);
+		break; case EditDeletePrev: if (pos) delete(false, --pos, 1);
+		break; case EditDeleteNext: delete(false, pos, 1);
 		break; case EditDeletePrevWord: {
 			if (!pos) break;
 			size_t word = pos - 1;
 			while (word && !iswspace(buf[word - 1])) word--;
-			delete(word, pos - word);
+			delete(true, word, pos - word);
 			pos = word;
 		}
 		break; case EditDeleteNextWord: {
 			if (pos == len) break;
 			size_t word = pos + 1;
 			while (word < len && !iswspace(buf[word])) word++;
-			delete(pos, word - pos);
+			delete(true, pos, word - pos);
 		}
 		break; case EditPaste: {
 			if (reserve(pos, cut.len)) {
324a70f87b689399bde631c&follow=1'>Add The Just CityJune McEnroe 2019-09-12Only GET the final redirect locationJune McEnroe 2019-09-12Consume entire bodyJune McEnroe Aborting the request and leaving data around may be causing intermittent errors. Just discard the rest of the data. 2019-09-10Add title -v flagJune McEnroe 2019-09-10Use curl error bufferJune McEnroe 2019-09-10Set Accept-Encoding in titleJune McEnroe Because apparently it's fine for servers to respond with Content-Encoding you didn't ask for, and curl won't decode it if you didn't ask for it. 2019-09-08Set title User-AgentJune McEnroe Some things don't like you if you don't send one. 2019-09-07Add -x flag to titleJune McEnroe 2019-09-07Ignore SIGPIPE in relayJune McEnroe Allows restarting consumers safely. 2019-09-07Add A Memory Called EmpireJune McEnroe 2019-09-05Handle lack of Content-TypeJune McEnroe 2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe Oops, didn't see this. 2019-09-05Decode entities in titlesJune McEnroe 2019-09-05Print title as soon as it's availableJune McEnroe 2019-09-05Use CURL_PREFIX to set flagsJune McEnroe 2019-09-05Add titleJune McEnroe 2019-09-04Add Avorter n'est pas tuerJune McEnroe 2019-08-29Unset executable on shell scriptsJune McEnroe 2019-08-29Add long-missing setopt to bin.7June McEnroe 2019-08-29Add editJune McEnroe