# File lib/rbreadline.rb, line 4259
  def _rl_isearch_fini(cxt)
    # First put back the original state.
    @rl_line_buffer = cxt.lines[cxt.save_line].dup
    rl_restore_prompt()

    # Save the search string for possible later use.
    @last_isearch_string = cxt.search_string
    @last_isearch_string_len = cxt.search_string_index
    cxt.search_string = nil

    if (cxt.last_found_line < cxt.save_line)
      rl_get_previous_history(cxt.save_line - cxt.last_found_line, 0)
    else
      rl_get_next_history(cxt.last_found_line - cxt.save_line, 0)
    end

    # If the string was not found, put point at the end of the last matching
    #   line.  If last_found_line == orig_line, we didn't find any matching
    #   history lines at all, so put point back in its original position.
    if (cxt.sline_index < 0)

      if (cxt.last_found_line == cxt.save_line)
        cxt.sline_index = cxt.save_point
      else
        cxt.sline_index = @rl_line_buffer.delete(0.chr).length
      end
      @rl_mark = cxt.save_mark
    end

    @rl_point = cxt.sline_index
    # Don't worry about where to put the mark here; rl_get_previous_history
    #   and rl_get_next_history take care of it.
    rl_clear_message()
  end