Skip to content

Commit 04bb8bc

Browse files
bitkeenjonathanslenders
authored andcommitted
Add has_suggestion filter
1 parent 8ce4065 commit 04bb8bc

File tree

1 file changed

+10
-0
lines changed
  • src/prompt_toolkit/filters

1 file changed

+10
-0
lines changed

src/prompt_toolkit/filters/app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"has_focus",
2121
"buffer_has_focus",
2222
"has_selection",
23+
"has_suggestion",
2324
"has_validation_error",
2425
"is_done",
2526
"is_read_only",
@@ -114,6 +115,15 @@ def has_selection() -> bool:
114115
return bool(get_app().current_buffer.selection_state)
115116

116117

118+
@Condition
119+
def has_suggestion() -> bool:
120+
"""
121+
Enable when the current buffer has a suggestion.
122+
"""
123+
buffer = get_app().current_buffer
124+
return buffer.suggestion is not None and buffer.suggestion.text != ""
125+
126+
117127
@Condition
118128
def has_completions() -> bool:
119129
"""

0 commit comments

Comments
 (0)