@@ -371,6 +371,35 @@ def _operator_in_selection(event: E) -> None:
371371 return operator_decorator
372372
373373
374+ @Condition
375+ def is_returnable () -> bool :
376+ return get_app ().current_buffer .is_returnable
377+
378+
379+ @Condition
380+ def in_block_selection () -> bool :
381+ buff = get_app ().current_buffer
382+ return bool (
383+ buff .selection_state and buff .selection_state .type == SelectionType .BLOCK
384+ )
385+
386+
387+ @Condition
388+ def digraph_symbol_1_given () -> bool :
389+ return get_app ().vi_state .digraph_symbol1 is not None
390+
391+
392+ @Condition
393+ def search_buffer_is_empty () -> bool :
394+ "Returns True when the search buffer is empty."
395+ return get_app ().current_buffer .text == ""
396+
397+
398+ @Condition
399+ def tilde_operator () -> bool :
400+ return get_app ().vi_state .tilde_operator
401+
402+
374403def load_vi_bindings () -> KeyBindingsBase :
375404 """
376405 Vi extensions.
@@ -410,7 +439,7 @@ def load_vi_bindings() -> KeyBindingsBase:
410439 (("g" , "~" ), Always (), lambda string : string .swapcase ()),
411440 (
412441 ("~" ,),
413- Condition ( lambda : get_app (). vi_state . tilde_operator ) ,
442+ tilde_operator ,
414443 lambda string : string .swapcase (),
415444 ),
416445 ]
@@ -528,10 +557,6 @@ def _cancel_completion(event: E) -> None:
528557 """
529558 event .current_buffer .cancel_completion ()
530559
531- @Condition
532- def is_returnable () -> bool :
533- return get_app ().current_buffer .is_returnable
534-
535560 # In navigation mode, pressing enter will always return the input.
536561 handle ("enter" , filter = vi_navigation_mode & is_returnable )(
537562 get_by_name ("accept-line" )
@@ -681,13 +706,6 @@ def _I(event: E) -> None:
681706 )
682707 )
683708
684- @Condition
685- def in_block_selection () -> bool :
686- buff = get_app ().current_buffer
687- return bool (
688- buff .selection_state and buff .selection_state .type == SelectionType .BLOCK
689- )
690-
691709 @handle ("I" , filter = in_block_selection & ~ is_read_only )
692710 def insert_in_block_selection (event : E , after : bool = False ) -> None :
693711 """
@@ -2071,10 +2089,6 @@ def _digraph(event: E) -> None:
20712089 """
20722090 event .app .vi_state .waiting_for_digraph = True
20732091
2074- @Condition
2075- def digraph_symbol_1_given () -> bool :
2076- return get_app ().vi_state .digraph_symbol1 is not None
2077-
20782092 @handle (Keys .Any , filter = vi_digraph_mode & ~ digraph_symbol_1_given )
20792093 def _digraph1 (event : E ) -> None :
20802094 """
@@ -2180,11 +2194,6 @@ def load_vi_search_bindings() -> KeyBindingsBase:
21802194 handle = key_bindings .add
21812195 from . import search
21822196
2183- @Condition
2184- def search_buffer_is_empty () -> bool :
2185- "Returns True when the search buffer is empty."
2186- return get_app ().current_buffer .text == ""
2187-
21882197 # Vi-style forward search.
21892198 handle (
21902199 "/" ,
0 commit comments