[listview] fix a couple of glitches with the selection

pull/1205/head
Tim Stack 10 months ago
parent 68b48fcc6a
commit 37eb9cfa36

@ -52,7 +52,7 @@ db_label_source::text_value_for_line(textview_curses& tc,
*/
label_out.clear();
if (row >= (int) this->dls_rows.size()) {
if (row < 0_vl || row >= (int) this->dls_rows.size()) {
return;
}
for (int lpc = 0; lpc < (int) this->dls_rows[row].size(); lpc++) {
@ -85,7 +85,7 @@ db_label_source::text_attrs_for_line(textview_curses& tc,
struct line_range lr(0, 0);
const struct line_range lr2(0, -1);
if (row >= (int) this->dls_rows.size()) {
if (row < 0_vl || row >= (int) this->dls_rows.size()) {
return;
}
auto alt_row_index = row % 4;

@ -380,12 +380,14 @@ handle_paging_key(int ch)
case 'J':
if (tc->is_selectable()) {
tc->toggle_user_mark(&textview_curses::BM_USER,
tc->get_selection());
lnav_data.ld_select_start[tc] = tc->get_selection();
lnav_data.ld_last_user_mark[tc] = tc->get_selection();
if (tc->get_selection() + 1_vl < tc->get_inner_height()) {
tc->set_selection(tc->get_selection() + 1_vl);
if (tc->get_selection() >= 0_vl) {
tc->toggle_user_mark(&textview_curses::BM_USER,
tc->get_selection());
lnav_data.ld_select_start[tc] = tc->get_selection();
lnav_data.ld_last_user_mark[tc] = tc->get_selection();
if (tc->get_selection() + 1_vl < tc->get_inner_height()) {
tc->set_selection(tc->get_selection() + 1_vl);
}
}
} else {
if (lnav_data.ld_last_user_mark.find(tc)

@ -114,8 +114,11 @@ listview_curses::reload_data()
} else if (this->lv_selection >= this->get_inner_height()) {
this->set_selection(this->get_inner_height() - 1_vl);
} else {
auto curr_sel = this->lv_selection;
auto curr_sel = this->get_selection();
if (curr_sel == -1_vl) {
curr_sel = 0_vl;
}
this->lv_selection = -1_vl;
this->set_selection(curr_sel);
}

@ -236,7 +236,7 @@ public:
vis_line_t get_selection() const
{
if (this->lv_selectable) {
if (this->lv_selectable && this->lv_selection != -1_vl) {
return this->lv_selection;
}
return this->lv_top;

Loading…
Cancel
Save