mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-21 23:11:17 -03:00
Do not add a space after completion if one is already there
Example: type `cd --help --help`, move the cursor inside the first `--help` and press tab. This used to add redundant spaces.
This commit is contained in:
committed by
Mahmoud Al-Qudsi
parent
22811ebcf6
commit
8baea8b157
@@ -1146,6 +1146,7 @@ wcstring completion_apply_to_command_line(const wcstring &val, complete_flags_t
|
||||
|
||||
const size_t cursor_pos = *inout_cursor_pos;
|
||||
bool back_into_trailing_quote = false;
|
||||
bool have_space_after_token = command_line[cursor_pos] == L' ';
|
||||
|
||||
if (do_replace) {
|
||||
size_t move_cursor;
|
||||
@@ -1168,7 +1169,7 @@ wcstring completion_apply_to_command_line(const wcstring &val, complete_flags_t
|
||||
}
|
||||
|
||||
if (add_space) {
|
||||
sb.append(L" ");
|
||||
if (!have_space_after_token) sb.append(L" ");
|
||||
move_cursor += 1;
|
||||
}
|
||||
sb.append(end);
|
||||
@@ -1217,7 +1218,8 @@ wcstring completion_apply_to_command_line(const wcstring &val, complete_flags_t
|
||||
// This is a quoted parameter, first print a quote.
|
||||
result.insert(new_cursor_pos++, wcstring("e, 1));
|
||||
}
|
||||
result.insert(new_cursor_pos++, L" ");
|
||||
if (!have_space_after_token) result.insert(new_cursor_pos, L" ");
|
||||
new_cursor_pos++;
|
||||
}
|
||||
*inout_cursor_pos = new_cursor_pos;
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user