duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit 1d5816f9012deea2bcd6a909e96ccbc04b18a906
parent e34038044db5085567c0fcc44eb8459f4e8ed2f7
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun,  5 Feb 2023 08:12:06 -0500

text/ed: fix crash on deleting last line of buffer

Diffstat:
Mfs/tests/text/ed.fs | 4++++
Mfs/text/ed.fs | 2+-
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/tests/text/ed.fs b/fs/tests/text/ed.fs @@ -4,6 +4,10 @@ ?f<< /text/ed.fs testbegin \ Ed tests +edbuf :empty +edbuf :linecnt 1 #eq +1 edbuf :dellines +edbuf :linecnt 1 #eq f" /tests/txtfile" edload 1 g 5 capture l diff --git a/fs/text/ed.fs b/fs/text/ed.fs @@ -124,7 +124,7 @@ extends IO struct[ Edbuf neg V2 to+ Line cnt then rdrop rdrop ; : :dellines ( n self -- ) - over not if 2drop exit then >r \ V1=self + 2dup :linecnt 1- min not if 2drop exit then >r \ V1=self V1 sel V1 to' lines llfind drop llprev swap ( delpoint n ) V1 sel llitern ( delpoint tgt ) tuck swap ( tgt tgt prev ) ! ( tgt )