diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f1341273c..0e44acf50 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -33,6 +33,7 @@ Interactive improvements ------------------------ - The default command-not-found handler now reports a special error if there is a non-executable file (:issue:`8804`) - ``less`` and other interactive commands would occasionally be stopped when run in a pipeline with fish functions; this has been fixed (:issue:`8699`). +- Case-changing autosuggestions generated mid-token now correctly append only the suffix, instead of duplicating the token (:issue:`8820`). New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 3f005e056..a7fa2694c 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -3327,6 +3327,13 @@ static void test_complete() { completions.front().completion, completions.front().flags, cmdline, &where, false); do_test(newcmdline == L"touch test/complete_test/bracket\\[abc\\] "); + // #8820 + size_t cursor_pos = 11; + newcmdline = + completion_apply_to_command_line(L"Debug/", COMPLETE_REPLACES_TOKEN | COMPLETE_NO_SPACE, + L"mv debug debug", &cursor_pos, true); + do_test(newcmdline == L"mv debug Debug/"); + #ifndef __CYGWIN__ // Square brackets are not legal path characters on WIN32/CYGWIN cmdline = LR"(touch test/complete_test/gnarlybracket\\[)"; completions = do_complete(cmdline, {}); diff --git a/src/reader.cpp b/src/reader.cpp index ed198114e..c8c664c31 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -1615,8 +1615,7 @@ wcstring completion_apply_to_command_line(const wcstring &val, complete_flags_t const wchar_t *begin, *end; const wchar_t *buff = command_line.c_str(); - parse_util_token_extent(buff, cursor_pos, &begin, nullptr, nullptr, nullptr); - end = buff + cursor_pos; + parse_util_token_extent(buff, cursor_pos, &begin, &end, nullptr, nullptr); wcstring sb(buff, begin - buff);