[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] ed: shift curNum after inserting a line before it
From:       Sergei Antonov <saproj () gmail ! com>
Date:       2023-04-29 8:40:24
Message-ID: 20230429084024.302826-1-saproj () gmail ! com
[Download RAW message or body]

Steps to reproduce the bug:
echo "A
B
C
D" > file
ed file << END
1
i
a
.
w
q
END
---
 editors/ed.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/editors/ed.c b/editors/ed.c
index 4a84f7433808..de40614bb213 100644
--- a/editors/ed.c
+++ b/editors/ed.c
@@ -346,6 +346,8 @@ static int insertLine(int num, const char *data, int len)
 	lp->prev = newLp;
 
 	lastNum++;
+	if (curNum > 0 && curNum >= num)
+		curNum++;
 	dirty = TRUE;
 	return setCurNum(num);
 }
-- 
2.37.2

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic