diff options
author | Ron Yorston <rmy@pobox.com> | 2024-07-18 15:01:22 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-07-18 15:02:54 +0100 |
commit | b1813ca864ed04f28b8ae0121c913fbe16aab8ee (patch) | |
tree | 68113aa6c7e292425f1243919897070fa323d205 /editors | |
parent | e68706f141f9f30e8dfccb3c0fec480dc68dbd32 (diff) | |
download | busybox-w32-b1813ca864ed04f28b8ae0121c913fbe16aab8ee.tar.gz busybox-w32-b1813ca864ed04f28b8ae0121c913fbe16aab8ee.tar.bz2 busybox-w32-b1813ca864ed04f28b8ae0121c913fbe16aab8ee.zip |
ed: fix line insertion before current line
When text is inserted by insertLine() the lines following the
insertion are moved down and the insertion point is made the new
current line. To avoid too much scanning of the linked list of
lines setCurNum() may use the position of the old current line to
determine the location of the new current line.
If the insertion point is before the old current line in the file
the latter will have been moved down, so its line pointer needs to
be adjusted.
(GitHub issue #431)
Diffstat (limited to 'editors')
-rw-r--r-- | editors/ed.c | 4 |
1 files changed, 4 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); |