From: Christian Heller Date: Wed, 11 Jun 2025 13:00:48 +0000 (+0200) Subject: On prompt history scroll-down, if at idx=0 on non-empty buffer, push it up into history. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%22https:/validator.w3.org/index.html?a=commitdiff_plain;h=336e54323ff6f179bedc7601a92a9b856c179f28;p=ircplom On prompt history scroll-down, if at idx=0 on non-empty buffer, push it up into history. --- diff --git a/ircplom.py b/ircplom.py index a603d0e..83870d1 100755 --- a/ircplom.py +++ b/ircplom.py @@ -541,6 +541,7 @@ class PromptWidget(ScrollableWidget): _y: int _width: int _prompt: str = PROMPT_TEMPLATE + _history_idx = 0 def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) @@ -593,14 +594,17 @@ class PromptWidget(ScrollableWidget): self._clear() self._history_idx -= 1 self._history_idx -= 1 - elif (not up) and self._history_idx < 0: - self._history_idx += 1 - if self._history_idx == 0: + self._input_buffer = self._history[self._history_idx][:] + elif not up: + if self._history_idx < 0: + self._history_idx += 1 + if self._history_idx == 0: + self._clear() + else: + self._input_buffer = self._history[self._history_idx][:] + elif self._input_buffer: + self._history += [self._input_buffer[:]] self._clear() - return - else: - return - self._input_buffer = self._history[self._history_idx][:] def cmd__backspace(self) -> None: 'Truncate current content by one character, if possible.'