mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 08:13:40 -05:00
FZF_KEY enhancements
* 'enter' instead of 'ctrl-m' * 'space' instead of ' '
This commit is contained in:
@@ -1607,4 +1607,49 @@ class TestCore < TestInteractive
|
||||
assert_equal 4, lines.match_count
|
||||
end
|
||||
end
|
||||
|
||||
def test_env_vars
|
||||
def to_vars(lines)
|
||||
lines.select { it.start_with?('FZF_') }.to_h do
|
||||
key, val = it.split('=', 2)
|
||||
[key.to_sym, val]
|
||||
end
|
||||
end
|
||||
|
||||
tmux.send_keys %(seq 100 | #{FZF} --multi --reverse --preview-window up,noborder --preview 'env | grep ^FZF_ | sort' --no-input --bind enter:show-input+refresh-preview,space:disable-search+refresh-preview), :Enter
|
||||
expected = {
|
||||
FZF_TOTAL_COUNT: '100',
|
||||
FZF_MATCH_COUNT: '100',
|
||||
FZF_SELECT_COUNT: '0',
|
||||
FZF_ACTION: 'start',
|
||||
FZF_KEY: '',
|
||||
FZF_POS: '1',
|
||||
FZF_QUERY: '',
|
||||
FZF_PROMPT: '>',
|
||||
FZF_INPUT_STATE: 'hidden'
|
||||
}
|
||||
tmux.until do |lines|
|
||||
assert_equal expected, to_vars(lines).slice(*expected.keys)
|
||||
end
|
||||
tmux.send_keys :Enter
|
||||
tmux.until do |lines|
|
||||
expected.merge!(FZF_INPUT_STATE: 'enabled', FZF_ACTION: 'show-input', FZF_KEY: 'enter')
|
||||
assert_equal expected, to_vars(lines).slice(*expected.keys)
|
||||
end
|
||||
tmux.send_keys :Tab, :Tab
|
||||
tmux.until do |lines|
|
||||
expected.merge!(FZF_ACTION: 'toggle-down', FZF_KEY: 'tab', FZF_POS: '3', FZF_SELECT_COUNT: '2')
|
||||
assert_equal expected, to_vars(lines).slice(*expected.keys)
|
||||
end
|
||||
tmux.send_keys '99'
|
||||
tmux.until do |lines|
|
||||
expected.merge!(FZF_ACTION: 'char', FZF_KEY: '9', FZF_QUERY: '99', FZF_MATCH_COUNT: '1', FZF_POS: '1')
|
||||
assert_equal expected, to_vars(lines).slice(*expected.keys)
|
||||
end
|
||||
tmux.send_keys :Space
|
||||
tmux.until do |lines|
|
||||
expected.merge!(FZF_INPUT_STATE: 'disabled', FZF_ACTION: 'disable-search', FZF_KEY: 'space')
|
||||
assert_equal expected, to_vars(lines).slice(*expected.keys)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user