@@ -371,6 +371,35 @@ def _operator_in_selection(event: E) -> None:
371
371
return operator_decorator
372
372
373
373
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
+
374
403
def load_vi_bindings () -> KeyBindingsBase :
375
404
"""
376
405
Vi extensions.
@@ -410,7 +439,7 @@ def load_vi_bindings() -> KeyBindingsBase:
410
439
(("g" , "~" ), Always (), lambda string : string .swapcase ()),
411
440
(
412
441
("~" ,),
413
- Condition ( lambda : get_app (). vi_state . tilde_operator ) ,
442
+ tilde_operator ,
414
443
lambda string : string .swapcase (),
415
444
),
416
445
]
@@ -528,10 +557,6 @@ def _cancel_completion(event: E) -> None:
528
557
"""
529
558
event .current_buffer .cancel_completion ()
530
559
531
- @Condition
532
- def is_returnable () -> bool :
533
- return get_app ().current_buffer .is_returnable
534
-
535
560
# In navigation mode, pressing enter will always return the input.
536
561
handle ("enter" , filter = vi_navigation_mode & is_returnable )(
537
562
get_by_name ("accept-line" )
@@ -681,13 +706,6 @@ def _I(event: E) -> None:
681
706
)
682
707
)
683
708
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
-
691
709
@handle ("I" , filter = in_block_selection & ~ is_read_only )
692
710
def insert_in_block_selection (event : E , after : bool = False ) -> None :
693
711
"""
@@ -2071,10 +2089,6 @@ def _digraph(event: E) -> None:
2071
2089
"""
2072
2090
event .app .vi_state .waiting_for_digraph = True
2073
2091
2074
- @Condition
2075
- def digraph_symbol_1_given () -> bool :
2076
- return get_app ().vi_state .digraph_symbol1 is not None
2077
-
2078
2092
@handle (Keys .Any , filter = vi_digraph_mode & ~ digraph_symbol_1_given )
2079
2093
def _digraph1 (event : E ) -> None :
2080
2094
"""
@@ -2180,11 +2194,6 @@ def load_vi_search_bindings() -> KeyBindingsBase:
2180
2194
handle = key_bindings .add
2181
2195
from . import search
2182
2196
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
-
2188
2197
# Vi-style forward search.
2189
2198
handle (
2190
2199
"/" ,
0 commit comments