]> git.neil.brown.name Git - edlib.git/commitdiff
render-lines: call_render_line_to_point never returns error
authorNeilBrown <neil@brown.name>
Tue, 8 Aug 2023 22:44:02 +0000 (08:44 +1000)
committerNeilBrown <neil@brown.name>
Fri, 11 Aug 2023 04:33:26 +0000 (14:33 +1000)
Don't test for call_render_line_to_point returning < 0, as it doesn't.
Don't even test for == 0.  That is a valid answer and we no longer call
call_render_line_to_point() in a situation where that causes problems.

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

index 346ab4bd5bc0463e558cd214c8ab5432a0baaaad..0eb4a15d964ef3facb5a7cc3ff2c40929e787e57 100644 (file)
@@ -16,7 +16,7 @@ the file.
 - [ ] should pane ->cx,cy be a struct xy??
 - [X] revalidate_start shouldn't find cursor on line where it is known
       not to be
-- [ ] call_render_line_to_point() never returns negative - why do we check?
+- [X] call_render_line_to_point() never returns negative - why do we check?
 - [ ] should pane_resize() report if any change happened?
 - [ ] I think I want a "Workspaces" concept, maybe tabbed set of tile
       collections.  I would have one of mail and one for each project
index 1f65d00fa7e0f9edcc9cbc57d4f4f6b5d2e058d1..50dcbc225855d9b2d553ecbac4ed8c7e6e991564 100644 (file)
@@ -1137,17 +1137,15 @@ static int revalidate_start(struct rl_data *rl safe,
                         */
                        int offset = call_render_line_to_point(focus,
                                                               pm, m);
-                       if (offset >= 0) {
-                               measure_line(p, focus, m, offset);
-                               if (hp->cy >= rl->skip_height + rl->margin)
-                                       /* Cursor is visible on this line
-                                        * and after margin from top.
-                                        */
-                                       on_screen = True;
-                               else if (start_of_file && rl->skip_height == 0)
-                                       /* Cannot make more margin space */
-                                       on_screen = True;
-                       }
+                       measure_line(p, focus, m, offset);
+                       if (hp->cy >= rl->skip_height + rl->margin)
+                               /* Cursor is visible on this line
+                                * and after margin from top.
+                                */
+                               on_screen = True;
+                       else if (start_of_file && rl->skip_height == 0)
+                               /* Cannot make more margin space */
+                               on_screen = True;
                } else if (pm && m2 && y >= p->h && m->seq < pm->seq &&
                           mark_ordered_not_same(pm, m2)) {
                        /* point might be in this line, but off end
@@ -1155,17 +1153,16 @@ static int revalidate_start(struct rl_data *rl safe,
                         */
                        int offset = call_render_line_to_point(focus,
                                                               pm, m);
-                       if (offset > 0) {
-                               int lh;
-                               measure_line(p, focus, m, offset);
-                               lh = attr_find_int(hp->attrs,
-                                                  "line-height");
-                               if (lh <= 0)
-                                       lh = 1;
-                               if (y - hp->h + hp->cy <= p->h - lh - rl->margin) {
-                                       /* Cursor is on screen */
-                                       on_screen = True;
-                               }
+                       int lh;
+                       measure_line(p, focus, m, offset);
+                       lh = attr_find_int(hp->attrs,
+                                          "line-height");
+                       if (lh <= 0)
+                               lh = 1;
+                       if (hp->cy >= 0 &&
+                           y - hp->h + hp->cy <= p->h - lh - rl->margin) {
+                               /* Cursor is on screen */
+                               on_screen = True;
                        }
                } else if (pm && mark_ordered_or_same(m, pm) && m2 &&
                           (mark_ordered_not_same(pm, m2) ||
@@ -1179,18 +1176,16 @@ static int revalidate_start(struct rl_data *rl safe,
                        else {
                                int offset = call_render_line_to_point(
                                        focus, pm, m);
-                               if (offset > 0) {
-                                       int lh;
-                                       int cy;
-                                       measure_line(p, focus, m, offset);
-                                       lh = attr_find_int(hp->attrs,
-                                                          "line-height");
-                                       cy = y - hp->h + hp->cy;
-                                       if (cy >= rl->margin &&
-                                           cy <= p->h - rl->margin - lh)
-                                               /* Cursor at least margin from edge */
-                                               on_screen = True;
-                               }
+                               int lh;
+                               int cy;
+                               measure_line(p, focus, m, offset);
+                               lh = attr_find_int(hp->attrs,
+                                                  "line-height");
+                               cy = y - hp->h + hp->cy;
+                               if (cy >= rl->margin &&
+                                   cy <= p->h - rl->margin - lh)
+                                       /* Cursor at least margin from edge */
+                                       on_screen = True;
                        }
                }
        }
@@ -1625,8 +1620,6 @@ DEF_CMD(render_lines_action)
        if (!v || !v->mdata || !mark_ordered_or_same(v, m))
                return Efallthrough;
        offset = call_render_line_to_point(focus, m, v);
-       if (offset < 0)
-               return Efallthrough;
        measure_line(p, focus, v, offset, &attr);
        if (!attr)
                return Efallthrough;