diff options
-rw-r--r-- | editors/ed.c | 4 | ||||
-rwxr-xr-x | testsuite/ed.tests | 21 |
2 files changed, 25 insertions, 0 deletions
diff --git a/editors/ed.c b/editors/ed.c index 8ec23d07f..e25179ddc 100644 --- a/editors/ed.c +++ b/editors/ed.c | |||
@@ -345,6 +345,10 @@ static int insertLine(int num, const char *data, int len) | |||
345 | lp->prev->next = newLp; | 345 | lp->prev->next = newLp; |
346 | lp->prev = newLp; | 346 | lp->prev = newLp; |
347 | 347 | ||
348 | #if ENABLE_PLATFORM_MINGW32 | ||
349 | if (num <= curNum) | ||
350 | curLine = curLine->prev; | ||
351 | #endif | ||
348 | lastNum++; | 352 | lastNum++; |
349 | dirty = TRUE; | 353 | dirty = TRUE; |
350 | return setCurNum(num); | 354 | return setCurNum(num); |
diff --git a/testsuite/ed.tests b/testsuite/ed.tests new file mode 100755 index 000000000..475fdc244 --- /dev/null +++ b/testsuite/ed.tests | |||
@@ -0,0 +1,21 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | . ./testing.sh | ||
4 | |||
5 | # testing "test name" "command" "expected result" "file input" "stdin" | ||
6 | |||
7 | testing "ed insert text before current line" \ | ||
8 | "ed input" "8\n1\ntext\n2\n3\n4\n13\n" "1\n2\n3\n4\n" '2i | ||
9 | text | ||
10 | . | ||
11 | ,p | ||
12 | w | ||
13 | q | ||
14 | ' | ||
15 | |||
16 | testing "ed read text before current line" \ | ||
17 | "ed input" "8\n8\n1\n2\n1\n2\n3\n4\n3\n4\n16\n" "1\n2\n3\n4\n" '2r input | ||
18 | ,p | ||
19 | w | ||
20 | q | ||
21 | ' | ||