]> git.neil.brown.name Git - edlib.git/commitdiff
linecount: fix need_recalc()
authorNeilBrown <neil@brown.name>
Sat, 3 Jun 2023 06:13:25 +0000 (16:13 +1000)
committerNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 05:40:21 +0000 (15:40 +1000)
I was testing the wrong thing - or freeing the wrong thing.

If a range is small - clear the first mark and discard the second.  Then
from the first to whatever comes next will be recalculated.

Signed-off-by: NeilBrown <neil@brown.name>
lib-linecount.c

index 5f119baa9ffd91a045b19c24e9abcb706326536b..110255a1949e5d6a0ac19aeb10faef293088e2fa 100644 (file)
@@ -105,14 +105,10 @@ static int need_recalc(struct pane *p safe, struct mark *m)
                return 1;
        if (!attr_find(*mark_attr(m), "lines"))
                ret = 1;
-       while (1) {
-               next = vmark_next(m);
-               if (!next)
-                       break;
-               if (is_eol(doc_prior(p, next)) &&
-                   attr_find_int(*mark_attr(next), "lines") > 10)
-                       break;
-               /* discard next - we'll find or create another */
+       next = vmark_next(m);
+       if (next && attr_find_int(*mark_attr(m), "lines") < 20) {
+               /* This is tiny, recalc */
+               attr_del(mark_attr(m), "lines");
                mark_free(next);
                ret = 1;
        }