code: def stop_search(buffer_control: BufferControl | None = None) -> None:
      """
      Stop search through the given `buffer_control`.
      """
      layout = get_app().layout
  
      if buffer_control is None:
          buffer_control = layout.search_target_buffer_control
          if buffer_control is None:
              # (Should not happen, but possible when `stop_search` is called
              # when we're not searching.)
              return
          search_buffer_control = buffer_control.search_buffer_control
      else:
          assert buffer_control in layout.search_links.values()
          search_buffer_control = _get_reverse_search_links(layout)[
              buffer_control
          ]
  
      # Focus the original buffer again.
      layout.focus(buffer_control)
  
      if search_buffer_control is not None:
          # Remove the search link.
          del layout.search_links[search_buffer_control]
  
          # Reset content of search control.
          search_buffer_control.buffer.reset()
  
      # If we're in Vi mode, go back to navigation mode.
      get_app().vi_state.input_mode = InputMode.NAVIGATION
  
file_path: catboost/contrib/python/prompt-toolkit/py3/prompt_toolkit/search.py
imports: from __future__ import annotations
  from enum import Enum
  from typing import TYPE_CHECKING
  from .application.current import get_app
  from .filters import FilterOrBool, is_searching, to_filter
  from .key_binding.vi_state import InputMode
label_desc: Use image node_id 2 for calling a global function with example usage: stop_search(buffer_control) without return types