summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-01-27 09:28:40 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-01-27 09:30:53 +0900
commit8179ca5eaa9241c71573a4f65ab34d21b8e3efb0 (patch)
tree511b48002d22eeb0613d53d9509f9ee14cbe5252
parent4b74f882c79600e4a988146d037eabf1fc484c7d (diff)
downloadfzf-8179ca5eaa9241c71573a4f65ab34d21b8e3efb0.tar.gz
Fix edge cases in --bind where ',' or ':' are chained (#4206)
-rw-r--r--src/options.go2
-rw-r--r--test/test_core.rb4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/options.go b/src/options.go
index 4d5d0ca2..79a70825 100644
--- a/src/options.go
+++ b/src/options.go
@@ -1387,6 +1387,8 @@ Loop:
masked += strings.Repeat(" ", loc[1])
action = action[loc[1]:]
}
+ masked = strings.ReplaceAll(masked, ",,,", string([]rune{',', escapedComma, ','}))
+ masked = strings.ReplaceAll(masked, ",:,", string([]rune{',', escapedColon, ','}))
masked = strings.ReplaceAll(masked, "::", string([]rune{escapedColon, ':'}))
masked = strings.ReplaceAll(masked, ",:", string([]rune{escapedComma, ':'}))
masked = strings.ReplaceAll(masked, "+:", string([]rune{escapedPlus, ':'}))
diff --git a/test/test_core.rb b/test/test_core.rb
index 21e400d4..5e47ef9d 100644
--- a/test/test_core.rb
+++ b/test/test_core.rb
@@ -418,9 +418,9 @@ class TestCore < TestInteractive
end
def test_bind
- tmux.send_keys "seq 1 1000 | #{fzf('-m --bind=ctrl-j:accept,u,U:up,X,Y,Z:toggle-up,t:toggle')}", :Enter
+ tmux.send_keys "seq 1 1000 | #{fzf('-m --bind=ctrl-j:accept,u,:,U:up,X,,,Z:toggle-up,t:toggle')}", :Enter
tmux.until { |lines| assert_equal ' 1000/1000 (0)', lines[-2] }
- tmux.send_keys 'uUu', 'XYZ', 'tt', 'uu', 'ttt', 'C-j'
+ tmux.send_keys 'uU:', 'X,Z', 'tt', 'uu', 'ttt', 'C-j'
assert_equal %w[4 5 6 9], fzf_output_lines
end