]> git.neil.brown.name Git - edlib.git/commitdiff
render-lines: split some complex conditions.
authorNeilBrown <neil@brown.name>
Mon, 10 May 2021 11:17:30 +0000 (21:17 +1000)
committerNeilBrown <neil@brown.name>
Mon, 10 May 2021 22:57:28 +0000 (08:57 +1000)
These conditions are too complex to easily understand.
Split them up to make them easier to explain.

Signed-off-by: NeilBrown <neil@brown.name>
render-lines.c

index 448540cd2f64ec5a47a7c8f984f152d9e2c60ead..179f380ff08eae5b0954fb443bafbaa79ef045e3 100644 (file)
@@ -596,18 +596,30 @@ static void find_lines(struct mark *pm safe, struct pane *p safe,
                         */
                        y_post = 0;
                if (!found_end && bot &&
-                   mark_ordered_or_same(start, bot) &&
-                   (!mark_same(start, bot) || y_pre - rl->skip_height >= y_post))
-                       /* FIXME: this needs some explanation */
+                   mark_ordered_not_same(start, bot))
+                       /* Overlap original from below, so prefer to
+                        * maximize that overlap.
+                        */
+                       found_end = True;
+
+               if (!found_end && bot && mark_same(start, bot) &&
+                   y_pre - rl->skip_height >= y_post)
+                       /* No overlap in marks yet, but over-lap in space,
+                        * so same result as above.
+                        */
                        found_end = True;
 
                if (!found_end && y_post <= 0)
                        /* step forwards */
                        found_end = step_fore(p, focus, &start, &end,
                                              &y_post, &line_height_post);
+
                if (!found_start && top && end &&
-                   mark_ordered_or_same(top, end) &&
-                   (!mark_same(top, end) || y_post - rl->tail_height >= y_pre))
+                   mark_ordered_not_same(top, end))
+                       found_start = True;
+
+               if (!found_start && top && end && mark_same(top, end)
+                   && y_post - rl->tail_height >= y_pre)
                        found_start = True;
 
                y = consume_space(p, y, &y_pre, &y_post,