@@ -81,15 +81,13 @@ def create_default_layout(app, message='',
8181
8282 # Create processors list.
8383 # (DefaultPrompt should always be at the end.)
84+ def search_highlighting (name ):
85+ return ConditionalProcessor (
86+ HighlightSearchProcessor (preview_search = PreviousFocus (name )),
87+ HasFocus (SEARCH_BUFFER ))
88+
8489 input_processors = [
85- ConditionalProcessor (
86- # By default, only highlight search when the search
87- # input has the focus. (Note that this doesn't mean
88- # there is no search: the Vi 'n' binding for instance
89- # still allows to jump to the next match in
90- # navigation mode.)
91- HighlightSearchProcessor (preview_search = Always ()),
92- HasFocus (SEARCH_BUFFER )),
90+ search_highlighting (DEFAULT_BUFFER ),
9391 HighlightSelectionProcessor (),
9492 ConditionalProcessor (
9593 AppendAutoSuggestion (), HasFocus (DEFAULT_BUFFER ) & ~ IsDone ()),
@@ -155,7 +153,7 @@ def separator():
155153 lexer = lexer ,
156154 # Enable preview_search, we want to have immediate
157155 # feedback in reverse-i-search mode.
158- preview_search = Always ( ),
156+ preview_search = PreviousFocus ( DEFAULT_BUFFER ),
159157 focus_on_click = True ,
160158 ),
161159 get_height = get_height ,
@@ -183,6 +181,8 @@ def separator():
183181 BufferControl (
184182 focus_on_click = True ,
185183 buffer_name = u'clidocs' ,
184+ input_processors = [search_highlighting (u'clidocs' )],
185+ preview_search = PreviousFocus (u'clidocs' ),
186186 ),
187187 height = LayoutDimension (max = 15 )),
188188 filter = HasDocumentation (app ) & ~ IsDone (),
@@ -233,3 +233,12 @@ def __init__(self, app):
233233
234234 def __call__ (self , cli ):
235235 return bool (self ._app .current_docs )
236+
237+ class PreviousFocus (Filter ):
238+ def __init__ (self , buffer_name ):
239+ self ._buffer_name = buffer_name
240+
241+ def __call__ (self , cli ):
242+ previous_buffer = cli .buffers .previous (cli )
243+ target_buffer = cli .buffers .get (self ._buffer_name )
244+ return previous_buffer is target_buffer
0 commit comments