From: NeilBrown Date: Tue, 8 Aug 2023 22:44:02 +0000 (+1000) Subject: render-lines: call_render_line_to_point never returns error X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=355425350289d9af62bb55f230417614108c9ce9;p=edlib.git render-lines: call_render_line_to_point never returns error 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 --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 346ab4bd..0eb4a15d 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -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 diff --git a/render-lines.c b/render-lines.c index 1f65d00f..50dcbc22 100644 --- a/render-lines.c +++ b/render-lines.c @@ -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;