Skip to content

Commit

Permalink
Clean Code
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbautista committed Nov 12, 2024
1 parent 7e6a582 commit 2d80419
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions qtconsole/history_console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def _show_history_droplist(self):
not (self._get_edited_history(self._history_index)[:pos] == input_buffer[:pos]):
self._history_prefix = input_buffer[:pos]
items = self._history
items.reverse()
if (self._history_prefix):
items = [item for item in items if item.startswith(self._history_prefix)]

Expand All @@ -204,13 +205,11 @@ def _show_history_droplist(self):
if len(items) == 1:
cursor.setPosition(self._control.textCursor().position(),
QtGui.QTextCursor.KeepAnchor)
cursor.insertText(items[0])
elif len(items) > 1:
current_pos = self._control.textCursor().position()
prefix = os.path.commonprefix(items)
if prefix:
cursor.setPosition(current_pos, QtGui.QTextCursor.KeepAnchor)
cursor.insertText(prefix)
current_pos = cursor.position()
self._history_list_widget.show_items(cursor, items,
prefix_length=len(prefix))
Expand Down

0 comments on commit 2d80419

Please sign in to comment.