mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-27 12:01:12 -03:00
Use the correct case in completion pager (#7744)
Consider $ complete -c foo -a 'aab aaB' -f $ foo A<TAB> since28d67c8we would insert the common prefix AND show the pager. Due to case-insensitive comparison, "b/B" was considered to be part of the prefix. Since the prefix is added to each pager item [1] we get wrong results. Fix this by removing the insensitive comparison between completions - I don't think it was of much use anyway. Commandline tokens are still matched case-insensitively, this is just about completions. Test this by running interactive fish inside tmux (pexpect's terminal emulation not have enough capabilities). Also add tests for recent interactive regressions #7526 and #7738. Closes #3978 [1]:b38a23awould solve this differently by giving every pager item its own prefix, but was reverted since it needs more fixes.
This commit is contained in:
committed by
GitHub
parent
211f8bc894
commit
7fea321b3e
@@ -1996,15 +1996,7 @@ bool reader_data_t::handle_completions(const completion_list_t &comp, size_t tok
|
||||
size_t idx, max = std::min(common_prefix.size(), el.completion.size());
|
||||
|
||||
for (idx = 0; idx < max; idx++) {
|
||||
wchar_t ac = common_prefix.at(idx), bc = el.completion.at(idx);
|
||||
bool matches = (ac == bc);
|
||||
// If we are replacing the token, allow case to vary.
|
||||
if (will_replace_token && !matches) {
|
||||
// Hackish way to compare two strings in a case insensitive way,
|
||||
// hopefully better than towlower().
|
||||
matches = (wcsncasecmp(&ac, &bc, 1) == 0);
|
||||
}
|
||||
if (!matches) break;
|
||||
if (common_prefix.at(idx) != el.completion.at(idx)) break;
|
||||
}
|
||||
|
||||
// idx is now the length of the new common prefix.
|
||||
|
||||
Reference in New Issue
Block a user