code: def document_for_search(self, search_state):
          
          search_result = self._search(search_state, include_current_position=True)
  
          if search_result is None:
              return self.document
          else:
              working_index, cursor_position = search_result
  
              # Keep selection, when `working_index` was not changed.
              if working_index == self.working_index:
                  selection = self.selection_state
              else:
                  selection = None
  
              return Document(self._working_lines[working_index],
                              cursor_position, selection=selection)
docs: Return a :class:`~prompt_toolkit.document.Document` instance that has
          the text/cursor position for this search, if we would apply it. This
          will be used in the
          :class:`~prompt_toolkit.layout.controls.BufferControl` to display
          feedback while searching.