From 336e54323ff6f179bedc7601a92a9b856c179f28 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Wed, 11 Jun 2025 15:00:48 +0200 Subject: [PATCH] On prompt history scroll-down, if at idx=0 on non-empty buffer, push it up into history. --- ircplom.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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.' -- 2.30.2