commit 06e7120499d5950ec210453f5db4824349b85455
parent 37805982e74a5b5ac6eab57e53ac3e6ba027c17b
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Thu, 23 Feb 2023 20:35:39 -0500
text/ed: fix movement rollover bug
Diffstat:
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/tests/text/ed.fs b/fs/tests/text/ed.fs
@@ -8,6 +8,7 @@ edbuf :linecnt 1 #eq
1 edbuf :dellines
edbuf :linecnt 1 #eq
f" /tests/txtfile" edload
+1 l- edbuf :lpos 0 #eq
1 g
5 capture c+
S" with some text\n ^\n1 / 17" #s=
diff --git a/fs/text/ed.fs b/fs/text/ed.fs
@@ -79,7 +79,7 @@ extends IO struct[ Edbuf
: _cbounds ( self -- ) bi+ :cpos | :sel Line cnt min swap _cpos! ;
: _lbounds ( idx self -- idx ) :linecnt 1- min ;
: :go ( idx self -- ) tuck _lbounds over _lpos! _cbounds ;
- : :godown ( n self -- ) tuck :lpos + swap :go ;
+ : :godown ( n self -- ) tuck :lpos + max0 swap :go ;
: _eol? ( self -- f ) bi :cpos | :sel Line cnt = ;
: :lastline? bi :lpos | :linecnt 1- = ;
: _eof? ( self -- f ) bi :lastline? | _eol? and ;