Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Upcoming (TBD)
==============

Bug Fixes
---------
* Force a prompt_toolkit refresh after fzf history search to avoid display glitches.


1.57.0 (2026/02/25)
==============

Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/toolkit/fzf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pyfzf import FzfPrompt

from mycli.packages.toolkit.history import FileHistoryWithTimestamp
from mycli.packages.toolkit.utils import safe_invalidate_display


class Fzf(FzfPrompt):
Expand Down Expand Up @@ -56,6 +57,7 @@ def search_history(event: KeyPressEvent, incremental: bool = False) -> None:
formatted_history_items,
fzf_options=' '.join(options),
)
safe_invalidate_display(event.app)

if result:
selected_index = formatted_history_items.index(result[0])
Expand Down
20 changes: 20 additions & 0 deletions mycli/packages/toolkit/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from prompt_toolkit.application import Application, run_in_terminal


def safe_invalidate_display(app: Application) -> None:
"""
fzf can confuse the terminal/app when certain values are set in
environment variable FZF_DEFAULT_OPTS.

The same could happen after running other external programs.

This function invalidates the prompt_toolkit display, causing a
refresh of the prompt message and pending user input, without
leading to exceptions at exit time, as the built-in
app.invalidate() does.
"""

def print_empty_string():
app.print_text('')

run_in_terminal(print_empty_string)