Test cases:
1. 'jump' should show alternating background colors even when 'alt-bg' is
not defined as before.
go run main.go --bind load:jump
Two differences:
* The alternating lines will not be in bold (was a bug)
* The marker column will not be rendered with alternating background color
2. Use alternating background color when 'alt-bg' is set
go run main.go --color bg:238,alt-bg:237
go run main.go --color bg:238,alt-bg:237 --highlight-line
3. 'selected-bg' should take precedence
go run main.go --color bg:238,alt-bg:237,selected-bg:232 \
--highlight-line --multi --bind 'load:select+up+select+up'
4. Should work with text with ANSI colors
declare -f | perl -0777 -pe 's/^}\n/}\0/gm' |
bat --plain --language bash --color always |
go run main.go --read0 --ansi --reverse --multi \
--color bg:237,alt-bg:238,current-bg:236 --highlight-line
---
Close#4354Fix#4372
This is a rewrite of __fzf_parse_commandline function, that fixes the
following issues, when CTRL-T/ALT-C is used and current command line
token contains:
- Escaped newlines (\n): This never worked correctly, but after 282884a,
the string would split, and the script would enter an infinite loop
while trying to set $dir.
- Escaped bell (\a, \cg), backspace (\b), form feed (\v, \cl), carriage
return (\r), vertical tab (\v, \ck): walker-root would not set
correctly for existing directories containing any of those characters.
- Regular expression special characters (^, +, ? etc): $dir would not be
be stripped from $fzf_query if it contained any of those characters.
The lowest supported fish version is v3.1b. For optimal operation, the
function uses more recent commands when supported by the running
version. Specifically, for versions equal or newer than:
- v3.2.0: Sets variables using PCRE2 capture groups of `string match
--regex` when needing to preserve any trailing newlines and
simultaneously omit the extra newline that is appended by `string
collect -N`.
- v3.5.0: Uses the builtin path command for path normalization, dirname
extraction and existing directories check.
- v4.0.0: Uses the --tokens-expanded option of commandline, for
expansion and dealing with unbalanced quotes and incomplete escape
sequences. It also uses the regex style of string-escape, to prepare
variable contents for regex operations. This is not used in older
versions, because they don't escape newlines.
CTRL-T/ALT-C now works correctly when selecting files or directories
that contain newlines in their names. When external commands defined by
$FZF_CTRL_T_COMMAND/$FZF_ALT_C_COMMAND are used (for example the fd
command with -0 switch), the --read0 option must also be set through
$FZF_CTRL_T_OPTS/$FZF_ALT_C_OPTS.
By default, placeholder expressions are automatically quoted to ensure
they are safely passed as arguments to external programs.
The r flag ({r}, {r1}, etc.) disables this behavior, outputting the
evaluated value without quotes.
For example,
echo 'foo bar' | fzf --preview 'echo {} {r}'
The preview command becomes:
echo 'foo bar' foo bar
Since `{r}` expands to unquoted "foo bar", 'foo' and 'bar' are passed
as separate arguments.
**Use with caution** Unquoted output can lead to broken commands.
echo "let's go" | fzf --preview 'echo {r}'
Close#4330
fzf would restore the original query in input-less mode after executing
a chain of actions.
This commit changes the behavior so that the restoration
happens after each action to allow something like
'show-input+change-query(...)+hide-input'.
Fix#4326