diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 35191e2b6..d18fe3d5a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -106,6 +106,7 @@ New or improved bindings - As mentioned above, new readline commands ``undo`` (Ctrl+_ or Ctrl+Z) and ``redo`` (Alt-/) can be used to revert changes to the command line or the pager search field (#6570). - Vi mode bindings now support ``dh``, ``dl``, ``c0``, ``cf``, ``ct``, ``cF``, ``cT``, ``ch``, ``cl``, and ``y0`` (#6648). +- Functions ``up-or-search`` and ``down-or-search`` (up-arrow and down-arrow) can cross empty lines and don't activate search mode if the search fails which makes it easier to use them to move between lines in some situations. - The readline command ``beginning-of-history`` (Page Up) now moves to the oldest search instead of the youngest - that's ``end-of-history`` (Page Down). - New readline command ``forward-single-char`` to move one character to the right, and if an autosuggestion is available, only take a single char from it (#7217). - New function ``__fish_preview_current_file`` (Alt+O) opens the diff --git a/src/parse_util.cpp b/src/parse_util.cpp index d05a99855..ced988d7a 100644 --- a/src/parse_util.cpp +++ b/src/parse_util.cpp @@ -83,7 +83,7 @@ size_t parse_util_get_offset_from_line(const wcstring &str, int line) { if (buff[i] == L'\n') { count++; if (count == line) { - return (i + 1) < str.size() ? i + 1 : i; + return i + 1; } } } diff --git a/src/reader.cpp b/src/reader.cpp index 7d045ed5f..f191c1730 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -3236,8 +3236,8 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat assert(base_pos_new != static_cast(-1) && base_pos_old != static_cast(-1)); - int indent_old = indents.at(base_pos_old); - int indent_new = indents.at(base_pos_new); + int indent_old = indents.at(std::min(indents.size() - 1, base_pos_old)); + int indent_new = indents.at(std::min(indents.size() - 1, base_pos_new)); size_t line_offset_old = el->position() - base_pos_old; size_t total_offset_new = parse_util_get_offset(