self._wrapped_idx_neg += 1
if self._newest_read_history_idx_pos < self._history_offset:
return
- bookmark_wrapped_idx_pos = (
- 0 if (not self._wrapped)
- else (1 + self._last_wrapped_idx_pos_for_hist_idx_pos(
- self._newest_read_history_idx_pos)))
- self._wrapped.insert(bookmark_wrapped_idx_pos, bookmark)
- if bookmark_wrapped_idx_pos - len(self._wrapped)\
- > self._wrapped_idx_neg:
- self._wrapped_idx_neg -= 1
+ if not self._wrapped:
+ return
+ self._wrapped.insert(self._bookmark_wrapped_idx_pos, bookmark)
+ self._wrapped_idx_neg -= int(self._bookmark_wrapped_idx_neg
+ > self._wrapped_idx_neg)
+
+ @property
+ def _bookmark_wrapped_idx_pos(self) -> int:
+ return self._last_wrapped_idx_pos_for_hist_idx_pos(
+ self._newest_read_history_idx_pos) + 1
+
+ @property
+ def _bookmark_wrapped_idx_neg(self) -> int:
+ return self._bookmark_wrapped_idx_pos - len(self._wrapped)
def _last_wrapped_idx_pos_for_hist_idx_pos(self, hist_idx_pos: int) -> int:
return [idx for idx, t in enumerate(self._wrapped)
else:
self._wrapped_idx_neg = min(
-1, self._wrapped_idx_neg + self._y_pgscroll)
- self._history_idx_neg\
- = (-self._len_full_history
- + max(0, self._wrapped[self._wrapped_idx_neg][0]))
+ idx = self._wrapped_idx_neg - int(
+ self._wrapped_idx_neg == self._bookmark_wrapped_idx_neg)
+ self._history_idx_neg = (-self._len_full_history
+ + max(0, self._wrapped[idx][0]))
class PromptWidget(_ScrollableWidget):