diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d5bcb2ccb..52fdd09be5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - Syntax highlighting for Python files using uv as script runner in shebang #3689 (@janlarres) ## Bugfixes +- Fix fish completions failing with `The expanded command was empty` when the completion file is first sourced inside a function, e.g. under a `` binding that calls `commandline --function complete`, see #4025 (@kokhlo) - Track strikethrough (SGR 9 / 29) in the ANSI style tracker so it is re-emitted like bold, dim, italic, and underline, and is no longer dropped after the first highlighted token when displaying ANSI input with syntax highlighting, see #4015 (@mikehasa) - Allow boolean flags to be given more than once, so that a flag set in the config file can also be passed on the command line without erroring, see #3912 (@logarithmone1128) - Use parsed CLI arguments to detect number flags, see #3908 (@cuishuang) diff --git a/assets/completions/bat.fish.in b/assets/completions/bat.fish.in index b2e356640f..38ff1270fe 100644 --- a/assets/completions/bat.fish.in +++ b/assets/completions/bat.fish.in @@ -3,7 +3,12 @@ # ($XDG_CONFIG_HOME is usually set to ~/.config) # `bat` is `batcat` on Debian and Ubuntu -set bat {{PROJECT_EXECUTABLE}} +# This has to be a global: fish sources completion files in the scope of the +# caller, so an unscoped `set` here would be local to whatever function +# happened to trigger the first completion (e.g. a custom binding that +# calls `commandline --function complete`). The helpers below run later, in a +# different scope, and would then see an empty `$bat`. +set -g bat {{PROJECT_EXECUTABLE}} # Helper functions: