Skip to content

Commit

Permalink
client: PR comments; replaced command history list with deque
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewMarinets committed May 17, 2024
1 parent 630b6b6 commit b900c78
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions kvui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import typing
import re
from collections import deque

if sys.platform == "win32":
import ctypes
Expand Down Expand Up @@ -396,15 +397,12 @@ class CommandPromptTextInput(TextInput):
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
self._command_history_index = -1
self._command_history: typing.List[str] = []
self._command_history: typing.Deque[str] = deque(maxlen=CommandPromptTextInput.MAXIMUM_HISTORY_MESSAGES)

def update_history(self, new_entry: str) -> None:
self._command_history_index = -1
if is_command_input(new_entry):
self._command_history = [
new_entry,
*self._command_history[:CommandPromptTextInput.MAXIMUM_HISTORY_MESSAGES-1]
]
self._command_history.appendleft(new_entry)

def keyboard_on_key_down(
self,
Expand Down

0 comments on commit b900c78

Please sign in to comment.