mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-07 17:43:53 +02:00
Fix an off-by-one error when scrolling back
This commit is contained in:
@@ -183,7 +183,7 @@ class Selection: # {{{
|
||||
|
||||
def line(y):
|
||||
if y < 0:
|
||||
return historybuf.line(-y)
|
||||
return historybuf.line(-1 - y)
|
||||
return linebuf.line(y)
|
||||
|
||||
lines = []
|
||||
@@ -286,7 +286,7 @@ class CharGrid:
|
||||
amt = {'line': 1, 'page': self.screen.lines - 1, 'full': self.screen.historybuf.count}[amt]
|
||||
if not upwards:
|
||||
amt *= -1
|
||||
y = max(0, min(self.scrolled_by + amt, self.screen.historybuf.count - 1))
|
||||
y = max(0, min(self.scrolled_by + amt, self.screen.historybuf.count))
|
||||
if y != self.scrolled_by:
|
||||
self.scrolled_by = y
|
||||
self.update_cell_data()
|
||||
@@ -298,7 +298,7 @@ class CharGrid:
|
||||
cursor_changed, history_line_added_count = self.screen.update_cell_data(
|
||||
sprites.backend, self.color_profile, addressof(self.main_sprite_map), self.default_fg, self.default_bg, force_full_refresh)
|
||||
if self.scrolled_by:
|
||||
self.scrolled_by = min(self.scrolled_by + history_line_added_count, self.screen.historybuf.count - 1)
|
||||
self.scrolled_by = min(self.scrolled_by + history_line_added_count, self.screen.historybuf.count)
|
||||
self.screen.set_scroll_cell_data(
|
||||
sprites.backend, self.color_profile, addressof(self.main_sprite_map), self.default_fg, self.default_bg,
|
||||
self.scrolled_by, addressof(self.scroll_sprite_map))
|
||||
@@ -370,7 +370,7 @@ class CharGrid:
|
||||
if y >= 0 and y < self.screen.lines:
|
||||
if self.scrolled_by:
|
||||
if y < self.scrolled_by:
|
||||
return self.screen.historybuf.line(self.scrolled_by - y)
|
||||
return self.screen.historybuf.line(self.scrolled_by - 1 - y)
|
||||
return self.screen.line(y - self.scrolled_by)
|
||||
else:
|
||||
return self.screen.line(y)
|
||||
|
||||
@@ -130,7 +130,7 @@ line(HistoryBuf *self, PyObject *val) {
|
||||
#define line_doc "Return the line with line number val. This buffer grows upwards, i.e. 0 is the most recently added line"
|
||||
if (self->count == 0) { PyErr_SetString(PyExc_IndexError, "This buffer is empty"); return NULL; }
|
||||
index_type lnum = PyLong_AsUnsignedLong(val);
|
||||
if (lnum > self->count - 1) { PyErr_SetString(PyExc_IndexError, "Out of bounds"); return NULL; }
|
||||
if (lnum >= self->count) { PyErr_SetString(PyExc_IndexError, "Out of bounds"); return NULL; }
|
||||
init_line(self, index_of(self, lnum), self->line);
|
||||
Py_INCREF(self->line);
|
||||
return (PyObject*)self->line;
|
||||
|
||||
@@ -1080,7 +1080,7 @@ set_scroll_cell_data(Screen *self, PyObject *args) {
|
||||
scrolled_by = MIN(self->historybuf->count, scrolled_by);
|
||||
|
||||
for (index_type y = 0; y < MIN(self->lines, scrolled_by); y++) {
|
||||
historybuf_init_line(self->historybuf, scrolled_by - y, self->historybuf->line);
|
||||
historybuf_init_line(self->historybuf, scrolled_by - 1 - y, self->historybuf->line);
|
||||
self->historybuf->line->ynum = y;
|
||||
if (!update_cell_range_data(&(self->modes), spm, self->historybuf->line, 0, self->columns - 1, color_profile, default_bg, default_fg, data)) return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user