diff options
-rw-r--r-- | fish_tests.cpp | 10 | ||||
-rw-r--r-- | history.cpp | 6 | ||||
-rw-r--r-- | reader.cpp | 22 |
3 files changed, 19 insertions, 19 deletions
diff --git a/fish_tests.cpp b/fish_tests.cpp index 7ce857b7..07ad1dc7 100644 --- a/fish_tests.cpp +++ b/fish_tests.cpp @@ -962,11 +962,11 @@ static void test_1_completion(wcstring line, const wcstring &completion, complet const size_t in_cursor_pos = line.find(L'^'); assert(in_cursor_pos != wcstring::npos); line.erase(in_cursor_pos, 1); - + const size_t out_cursor_pos = expected.find(L'^'); assert(out_cursor_pos != wcstring::npos); expected.erase(out_cursor_pos, 1); - + size_t cursor_pos = in_cursor_pos; wcstring result = completion_apply_to_command_line(completion, flags, line, &cursor_pos, append_only); if (result != expected) @@ -979,7 +979,7 @@ static void test_1_completion(wcstring line, const wcstring &completion, complet static void test_completions() { - #define TEST_1_COMPLETION(a, b, c, d, e) test_1_completion(a, b, c, d, e, __LINE__) +#define TEST_1_COMPLETION(a, b, c, d, e) test_1_completion(a, b, c, d, e, __LINE__) say(L"Testing completions"); TEST_1_COMPLETION(L"foo^", L"bar", 0, false, L"foobar ^"); TEST_1_COMPLETION(L"foo^ baz", L"bar", 0, false, L"foobar ^ baz"); //we really do want to insert two spaces here - otherwise it's hidden by the cursor @@ -987,7 +987,7 @@ static void test_completions() TEST_1_COMPLETION(L"'foo'^", L"bar", 0, false, L"'foobar' ^"); TEST_1_COMPLETION(L"'foo\\'^", L"bar", 0, false, L"'foo\\'bar' ^"); TEST_1_COMPLETION(L"foo\\'^", L"bar", 0, false, L"foo\\'bar ^"); - + // Test append only TEST_1_COMPLETION(L"foo^", L"bar", 0, true, L"foobar ^"); TEST_1_COMPLETION(L"foo^ baz", L"bar", 0, true, L"foobar ^ baz"); @@ -995,7 +995,7 @@ static void test_completions() TEST_1_COMPLETION(L"'foo'^", L"bar", 0, true, L"'foo'bar ^"); TEST_1_COMPLETION(L"'foo\\'^", L"bar", 0, true, L"'foo\\'bar' ^"); TEST_1_COMPLETION(L"foo\\'^", L"bar", 0, true, L"foo\\'bar ^"); - + TEST_1_COMPLETION(L"foo^", L"bar", COMPLETE_NO_SPACE, false, L"foobar^"); TEST_1_COMPLETION(L"'foo^", L"bar", COMPLETE_NO_SPACE, false, L"'foobar^"); TEST_1_COMPLETION(L"'foo'^", L"bar", COMPLETE_NO_SPACE, false, L"'foobar'^"); diff --git a/history.cpp b/history.cpp index 02e91366..873c0f62 100644 --- a/history.cpp +++ b/history.cpp @@ -1657,7 +1657,7 @@ void history_t::add_with_file_detection(const wcstring &str) { ASSERT_IS_MAIN_THREAD(); path_list_t potential_paths; - + /* Hack hack hack - if the command is likely to trigger an exit, then don't do background file detection, because we won't be able to write it to our history file before we exit. */ bool impending_exit = false; @@ -1674,14 +1674,14 @@ void history_t::add_with_file_detection(const wcstring &str) if (unescape_string(potential_path, false) && string_could_be_path(potential_path)) { potential_paths.push_back(potential_path); - + /* What a hack! */ impending_exit = impending_exit || contains(potential_path, L"exec", L"exit", L"reboot"); } } } } - + if (potential_paths.empty() || impending_exit) { this->add(str); @@ -950,7 +950,7 @@ wcstring completion_apply_to_command_line(const wcstring &val_str, complete_flag bool add_space = !(flags & COMPLETE_NO_SPACE); bool do_replace = !!(flags & COMPLETE_NO_CASE); bool do_escape = !(flags & COMPLETE_DONT_ESCAPE); - + const size_t cursor_pos = *inout_cursor_pos; bool back_into_trailing_quote = false; @@ -998,7 +998,7 @@ wcstring completion_apply_to_command_line(const wcstring &val_str, complete_flag if (do_escape) { parse_util_get_parameter_info(command_line, cursor_pos, "e, NULL, NULL); - + /* If the token is reported as unquoted, but ends with a (unescaped) quote, and we can modify the command line, then delete the trailing quote so that we can insert within the quotes instead of after them. See https://github.com/fish-shell/fish-shell/issues/552 */ if (quote == L'\0' && ! append_only && cursor_pos > 0) { @@ -1010,14 +1010,14 @@ wcstring completion_apply_to_command_line(const wcstring &val_str, complete_flag back_into_trailing_quote = true; } } - + replaced = parse_util_escape_string_with_quote(val_str, quote); } else { replaced = val; } - + size_t insertion_point = cursor_pos; if (back_into_trailing_quote) { @@ -1025,7 +1025,7 @@ wcstring completion_apply_to_command_line(const wcstring &val_str, complete_flag assert(insertion_point > 0); insertion_point--; } - + /* Perform the insertion and compute the new location */ wcstring result = command_line; result.insert(insertion_point, replaced); @@ -2740,7 +2740,7 @@ static bool is_backslashed(const wcstring &str, size_t pos) /* note pos == str.size() is OK */ if (pos > str.size()) return false; - + size_t count = 0, idx = pos; while (idx--) { @@ -2972,13 +2972,13 @@ const wchar_t *reader_readline() /* Clear the completion list */ comp.clear(); - + /* Figure out the extent of the command substitution surrounding the cursor. This is because we only look at the current command substitution to form completions - stuff happening outside of it is not interesting. */ parse_util_cmdsubst_extent(buff, data->buff_pos, &cmdsub_begin, &cmdsub_end); - + /* Figure out the extent of the token within the command substitution. Note we pass cmdsub_begin here, not buff */ parse_util_token_extent(cmdsub_begin, data->buff_pos - (cmdsub_begin-buff), &token_begin, &token_end, 0, 0); - + /* Figure out how many steps to get from the current position to the end of the current token. */ size_t end_of_token_offset = token_end - buff; @@ -2988,13 +2988,13 @@ const wchar_t *reader_readline() data->buff_pos = end_of_token_offset; reader_repaint(); } - + /* Remove a trailing backslash. This may trigger an extra repaint, but this is rare. */ if (is_backslashed(data->command_line, data->buff_pos)) { remove_backward(); } - + /* Construct a copy of the string from the beginning of the command substitution up to the end of the token we're completing */ const wcstring buffcpy = wcstring(cmdsub_begin, token_end); |