[bottom_status] fix out-of-bounds when with word-wrap

Related to #1058
This commit is contained in:
Tim Stack 2022-09-16 11:20:15 -07:00
parent bfa8ae2c42
commit 116b40f28c
2 changed files with 11 additions and 16 deletions

View File

@ -69,21 +69,16 @@ bottom_status_source::update_line_number(listview_curses* lc)
sf.set_value(" L%'d", (int) lc->get_top()); sf.set_value(" L%'d", (int) lc->get_top());
} }
if (lc->get_inner_height() > 0) { this->bss_line_error.set_value(
std::vector<attr_line_t> rows(1); lc->map_top_row([](const attr_line_t& top_row)
-> nonstd::optional<std::string> {
lc->get_data_source()->listview_value_for_rows( const auto& sa = top_row.get_attrs();
*lc, lc->get_top(), rows); auto error_wrapper = get_string_attr(sa, SA_ERROR);
const auto& sa = rows[0].get_attrs(); if (error_wrapper) {
auto error_wrapper = get_string_attr(sa, SA_ERROR); return error_wrapper.value().get();
if (error_wrapper) { }
this->bss_line_error.set_value(error_wrapper.value().get()); return nonstd::nullopt;
} else { }).value_or(""));
this->bss_line_error.clear();
}
} else {
this->bss_line_error.clear();
}
} }
void void

View File

@ -244,7 +244,7 @@ public:
auto map_top_row(F func) -> auto map_top_row(F func) ->
typename std::result_of<F(const attr_line_t&)>::type typename std::result_of<F(const attr_line_t&)>::type
{ {
if (this->get_inner_height() == 0) { if (this->lv_top >= this->get_inner_height()) {
return nonstd::nullopt; return nonstd::nullopt;
} }