fish-shell/src
Johannes Altmanninger 92582d5b1f Back out "Escape : and = in file completions"
If you don't care about file paths containing '=' or ':', you can
stop reading now.

In tokens like

	env var=/some/path
	PATH=/bin:/usr/local/b

file completion starts after the last separator (#2178).

Commit db365b5ef8 (Do not treat \: or \= as file completion anchor,
2024-04-19) allowed to override this behavior by escaping separators,
matching Bash.

Commit e97a4fab71 (Escape : and = in file completions, 2024-04-19)
adds this escaping automatically (also matching Bash).

The automatic escaping can be jarring and confusing, because separators
have basically no special meaning in the tokenizer; the escaping is
purely a hint to the completion engine, and often unnecessary.

For "/path/to/some:file", we compute completions for "file" and for
"/path/to/some:file".  Usually the former already matches nothing,
meaning that escaping isn't necessary.

e97a4fab71 refers us to f7dac82ed6 (Escape separators (colon and
equals) to improve completion, 2019-08-23) for the original motivation:

	$ ls /sys/bus/acpi/devices/d<tab>
	$ ls /sys/bus/acpi/devices/device:
	device:00/ device:0a/ …

Before automatic escaping, this scenario would suggest all files from
$PWD in addition to the expected completions shown above.

Since this seems to be mainly about the case where the suffix after
the separator is empty,

Let's remove the automatic escaping and add a heuristic to skip suffix
completions if:
1. the suffix is empty, to specifically address the above case.
2. the whole token completes to at least one appending completion.
   This makes sure that "git log -- :!:" still gets completions.
   (Not sure about the appending requirement)

This heuristic is probably too conservative; we can relax it later
should we hit this again.

Since this reverts most of e97a4fab71, we address the code clone
pointed out in 421ce13be6 (Fix replacing completions spuriously quoting
~, 2024-12-06). Note that e97a4fab71 quietly fixed completions for
variable overrides with brackets.

	a=bracket[

But it did so in a pretty intrusive way, forcing a lot of completions
to become replacing. Let's move this logic to a more appropriate place.

---

Additionally, we could sort every whole-token completion before every
suffix-completion.  That would probably improve the situation further,
but by itself it wouldn't address the immediate issue.

Closes #11027

(cherry picked from commit b6c249be0c)
2025-01-23 09:03:07 +08:00
..
bin Fix error for "fish --foo" without option argument 2025-01-17 09:52:53 +01:00
builtins type: Do not translate the type "builtin" 2025-01-09 16:41:44 +01:00
env Make fish installable 2024-12-06 22:12:26 +01:00
fork_exec Signals: Compute signal set once on startup 2024-12-04 20:18:16 +01:00
history Fix/suppress some clippies 2024-11-30 12:21:30 -08:00
tests Back out "Escape : and = in file completions" 2025-01-23 09:03:07 +08:00
universal_notifier Add kqueue-based uvar notifier for BSD (#10674) 2024-08-26 17:10:26 -05:00
widecharwidth Update widecharwidth for Unicode 16 2024-09-24 17:00:13 +02:00
wutil Silence clippy lints 2024-11-24 11:17:34 +01:00
abbrs.rs Replace C++ doc \return with "Return" 2024-05-06 14:59:36 -05:00
ast.rs Swap variable overrides and time in not statement 2024-12-16 06:33:47 +01:00
autoload.rs Replace C++ doc \return with "Return" 2024-05-06 14:59:36 -05:00
color.rs Fix/suppress some clippies 2024-11-30 12:21:30 -08:00
common.rs Back out "Escape : and = in file completions" 2025-01-23 09:03:07 +08:00
complete.rs Back out "Escape : and = in file completions" 2025-01-23 09:03:07 +08:00
curses.rs Remove yet more dead code 2024-06-29 18:03:52 -07:00
editable_line.rs Silence unused imports for backports 2024-10-26 22:28:37 +02:00
env_dispatch.rs curses: Just use our hardcoded xterm-256color entry as the fallback 2024-12-14 12:10:34 +01:00
env_universal_common.rs Revert libc time_t changes 2024-08-27 14:28:00 +02:00
event.rs Fix some clippies and remove some dead code 2024-11-17 12:37:45 -08:00
exec.rs Don't clone argv for builtins 2025-01-17 10:02:32 +01:00
expand.rs Do not add a space after completing inside brace expansion 2024-10-19 22:06:05 +02:00
fallback.rs Add ascii fast path for fish_wcswidth(&wstrw) 2024-11-22 21:35:39 -06:00
fd_monitor.rs Revert libc time_t changes 2024-08-27 14:28:00 +02:00
fd_readable_set.rs Revert libc time_t changes 2024-08-27 14:28:00 +02:00
fds.rs Fix typo 2024-10-09 12:36:58 +02:00
fish_test_helper.c fish_test_helper: Fix warnings about intentionally unused results 2024-08-31 13:16:51 -05:00
flog.rs Temporarily enable history_file debug category by default 2024-10-09 14:51:54 +02:00
function.rs fix: check whether a function is tombstoned during highlight 2024-11-27 08:44:36 +01:00
future_feature_flags.rs feature_flags: update target release for 3.8 flags to 4.0 2025-01-15 22:12:22 +08:00
future.rs Remove backports for 1.67 2024-04-29 22:00:59 +02:00
global_safety.rs Simplify shared-from-this pattern 2024-03-09 10:09:03 +01:00
highlight.rs Relax history autosuggestion and highlighting if cd is wrapped 2024-09-14 08:51:42 +02:00
history.rs Silence time_t deprecation 2024-12-14 09:34:52 +01:00
input_common.rs Workaround Kitty spamming the log for ModifyOtherKeys 2025-01-14 20:10:33 +01:00
input.rs Make new ctrl-c behavior "clear-commandline" 2025-01-14 20:00:31 +01:00
io.rs Clean up fd_monitor getter 2024-09-22 14:02:55 -07:00
job_group.rs Deduplicate jobs passed to disown builtin 2024-11-14 13:24:55 -06:00
key.rs bind: Remove "c-" and "a-" shortcut notation 2024-11-13 17:48:15 +01:00
kill.rs Remove L! from sprintf calls 2024-01-13 08:52:54 +01:00
lib.rs Clean up fish-printf in preparation for publishing 2024-09-21 17:52:11 -07:00
libc.c Revert libc time_t changes 2024-08-27 14:28:00 +02:00
libc.rs Revert libc time_t changes 2024-08-27 14:28:00 +02:00
locale.rs Remove some (hopefully) unnecessary clippy and compiler directives 2024-06-23 17:13:14 -07:00
nix.rs Revert libc time_t changes 2024-08-27 14:28:00 +02:00
null_terminated_array.rs Remove yet more dead code 2024-06-29 18:03:52 -07:00
operation_context.rs Make OperationContext not hold a Parser via Rc 2024-06-23 16:39:39 -07:00
output.rs Replace C++ doc \return with "Return" 2024-05-06 14:59:36 -05:00
pager.rs Also handle overflown screens if editing pager search field 2024-10-27 08:17:56 +01:00
panic.rs Prevent test suite from hanging on panic 2024-11-11 16:45:13 -06:00
parse_constants.rs Rename printf crate to fish-printf 2024-06-09 12:29:09 -07:00
parse_execution.rs Fix completion failing on unclosed brace with wildcard 2024-10-19 22:04:54 +02:00
parse_tree.rs Use NonZero types for 1-based line numbers 2024-07-07 20:58:09 -05:00
parse_util.rs edit_command_buffer: speed up setting cursor position by line/column 2024-11-01 20:09:55 +01:00
parser_keywords.rs Remove widestring-suffix uses 2024-01-13 08:52:54 +01:00
parser.rs Clean up some stale comments 2024-12-07 10:37:53 -08:00
path.rs Create new base directories with mode 0700 2024-12-28 12:14:14 -08:00
print_help.rs Clean up print_help 2024-11-17 17:03:34 -08:00
proc.rs Temporary workaround for BSD WEXITSTATUS libc bug 2024-12-23 14:43:37 +01:00
re.rs Move fish-rust to project root 2024-01-13 03:58:33 +01:00
reader_history_search.rs Replace C++ doc \return with "Return" 2024-05-06 14:59:36 -05:00
reader.rs Back out "Escape : and = in file completions" 2025-01-23 09:03:07 +08:00
redirection.rs Remove yet more dead code 2024-06-29 18:03:52 -07:00
screen.rs Clean up some stale comments 2024-12-07 10:37:53 -08:00
signal.rs Remove SIGUNUSED 2024-12-23 17:01:04 +01:00
termsize.rs Remove yet more dead code 2024-06-29 18:03:52 -07:00
threads.rs Update threads::thread_id() documentation 2024-08-31 12:57:13 -05:00
timer.rs Revert libc time_t changes 2024-08-27 14:28:00 +02:00
tinyexpr.rs math: Nicer error for non-ascii-lowercase identifiers 2024-09-18 22:27:00 +02:00
tokenizer.rs Refactor some more .unwrap/asserts 2024-11-30 23:11:04 +01:00
topic_monitor.rs Rename binary_semaphore_t to BinarySemaphore 2024-06-29 18:07:11 -07:00
trace.rs Remove parser library_data_pod_t ffi workaround 2024-06-02 20:27:44 -05:00
util.rs Stop using the getrandom feature of the rand crate 2024-10-13 12:39:54 -07:00
wait_handle.rs Use strongly typed Pid for job control 2024-11-14 13:02:03 -06:00
wchar_ext.rs Fix replacing completions with a -foo prefix 2024-12-14 09:31:20 +01:00
wchar.rs Clean up fish-printf in preparation for publishing 2024-09-21 17:52:11 -07:00
wcstringutil.rs Speed up get_case_fold() 5x 2024-11-22 16:30:10 -06:00
wgetopt.rs Reimplement WGetopter::exchange() using rotate_left 2024-04-17 12:41:16 -07:00
wildcard.rs Disable terminal protocols before cancellable operations 2024-11-24 16:11:57 +01:00