mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-31 04:13:49 -07:00
Implement --toggle-sort option (#173)
This commit is contained in:
@@ -70,8 +70,8 @@ func TestIrrelevantNth(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExpectKeys(t *testing.T) {
|
||||
keys := parseKeyChords("ctrl-z,alt-z,f2,@,Alt-a,!,ctrl-G,J,g")
|
||||
func TestParseKeys(t *testing.T) {
|
||||
keys := parseKeyChords("ctrl-z,alt-z,f2,@,Alt-a,!,ctrl-G,J,g", "")
|
||||
check := func(key int, expected int) {
|
||||
if key != expected {
|
||||
t.Errorf("%d != %d", key, expected)
|
||||
@@ -88,3 +88,44 @@ func TestExpectKeys(t *testing.T) {
|
||||
check(keys[7], curses.AltZ+'J')
|
||||
check(keys[8], curses.AltZ+'g')
|
||||
}
|
||||
|
||||
func TestParseKeysWithComma(t *testing.T) {
|
||||
check := func(key int, expected int) {
|
||||
if key != expected {
|
||||
t.Errorf("%d != %d", key, expected)
|
||||
}
|
||||
}
|
||||
|
||||
keys := parseKeyChords(",", "")
|
||||
check(len(keys), 1)
|
||||
check(keys[0], curses.AltZ+',')
|
||||
|
||||
keys = parseKeyChords(",,a,b", "")
|
||||
check(len(keys), 3)
|
||||
check(keys[0], curses.AltZ+'a')
|
||||
check(keys[1], curses.AltZ+'b')
|
||||
check(keys[2], curses.AltZ+',')
|
||||
|
||||
keys = parseKeyChords("a,b,,", "")
|
||||
check(len(keys), 3)
|
||||
check(keys[0], curses.AltZ+'a')
|
||||
check(keys[1], curses.AltZ+'b')
|
||||
check(keys[2], curses.AltZ+',')
|
||||
|
||||
keys = parseKeyChords("a,,,b", "")
|
||||
check(len(keys), 3)
|
||||
check(keys[0], curses.AltZ+'a')
|
||||
check(keys[1], curses.AltZ+'b')
|
||||
check(keys[2], curses.AltZ+',')
|
||||
|
||||
keys = parseKeyChords("a,,,b,c", "")
|
||||
check(len(keys), 4)
|
||||
check(keys[0], curses.AltZ+'a')
|
||||
check(keys[1], curses.AltZ+'b')
|
||||
check(keys[2], curses.AltZ+'c')
|
||||
check(keys[3], curses.AltZ+',')
|
||||
|
||||
keys = parseKeyChords(",,,", "")
|
||||
check(len(keys), 1)
|
||||
check(keys[0], curses.AltZ+',')
|
||||
}
|
||||
|
Reference in New Issue
Block a user