Fix BufferView repeating last line for the remainder of the view
This commit is contained in:
parent
22171cacf9
commit
d2fa28c5e1
@ -88,7 +88,8 @@ void BufferView::update()
|
||||
ld.line = std::make_shared<Buffer::Iterator>(*line_iterator);
|
||||
m_lines.push_back(ld);
|
||||
row_offset += ld.n_rows;
|
||||
line_iterator->go_next_line();
|
||||
if (!line_iterator->go_next_line())
|
||||
break;
|
||||
}
|
||||
|
||||
/* Reset some fields if buffer becomes empty. */
|
||||
|
@ -682,3 +682,19 @@ TEST(BufferViewTest, scrolls_window_through_a_very_long_single_line_file)
|
||||
EXPECT_EQ(9, bv.cursor_screen_row());
|
||||
EXPECT_EQ(1009u, **iterator);
|
||||
}
|
||||
|
||||
TEST(BufferViewTest, shows_only_lines_in_buffer_if_fewer_lines_in_buffer_than_view)
|
||||
{
|
||||
auto b = buffer1();
|
||||
auto iterator = b->add_iterator();
|
||||
BufferView bv(b, iterator, Cwd);
|
||||
bv.resize(50, 50);
|
||||
bv.update();
|
||||
int count = 0;
|
||||
for (auto it = bv.vert_iter(); it.is_valid(); it++)
|
||||
{
|
||||
EXPECT_EQ(count, it.row_offset());
|
||||
count++;
|
||||
}
|
||||
EXPECT_EQ(13, count);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user