xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit c020359ae28878b6dec7117ea3695ea314a146f5

Fix foreign keys followed by selectors/multikey
Need to set correct type.
Author: xaizek
Author date (UTC): 2022-03-07 15:33
Committer name: xaizek
Committer date (UTC): 2022-03-07 15:34
Parent(s): 6dd9900171982c0f9faf8f6b0bf5b6d44e6ec9b5
Signing key: 99DC5E4DB05F6BE2
Tree: c0d0e77ca9b638a67549b843fc4884204bcca795
File Lines added Lines deleted
src/engine/keys.c 2 1
tests/keys/foreign_keys.c 38 2
File src/engine/keys.c changed (mode: 100644) (index 851caff3d..d75cd8643)
... ... vle_keys_foreign_add(const wchar_t lhs[], const key_conf_t *info,
1013 1013 free(curr->conf.data.cmd); free(curr->conf.data.cmd);
1014 1014 } }
1015 1015
1016 curr->type = BUILTIN_KEYS;
1016 curr->type = (info->followed == FOLLOWED_BY_NONE) ? BUILTIN_KEYS
1017 : BUILTIN_WAIT_POINT;
1017 1018 curr->conf = *info; curr->conf = *info;
1018 1019 return 0; return 0;
1019 1020 } }
File tests/keys/foreign_keys.c changed (mode: 100644) (index 8e2c946bc..3549ba1f8)
... ... static void key_X(key_info_t key_info, keys_info_t *keys_info);
10 10 static void selector_X(key_info_t key_info, keys_info_t *keys_info); static void selector_X(key_info_t key_info, keys_info_t *keys_info);
11 11
12 12 static int called; static int called;
13 static int indexes_count;
14 static int multikey;
13 15
14 16 SETUP() SETUP()
15 17 { {
 
... ... TEST(foreign_selectors_can_be_cleared)
71 73 assert_true(IS_KEYS_RET_CODE(vle_keys_exec(L"d10X"))); assert_true(IS_KEYS_RET_CODE(vle_keys_exec(L"d10X")));
72 74 } }
73 75
76 TEST(add_foreign_key_with_selector)
77 {
78 key_conf_t selector = { { &selector_X } };
79 assert_success(vle_keys_foreign_add(L"X", &selector, /*is_selector=*/1,
80 NORMAL_MODE));
81
82 key_conf_t key = { { &key_X }, .followed = FOLLOWED_BY_SELECTOR };
83 assert_success(vle_keys_foreign_add(L"X", &key, /*is_selector=*/0,
84 NORMAL_MODE));
85 assert_true(vle_keys_user_exists(L"X", NORMAL_MODE));
86
87 indexes_count = 0;
88 assert_int_equal(KEYS_WAIT, vle_keys_exec(L"X"));
89 assert_false(IS_KEYS_RET_CODE(vle_keys_exec(L"X4X")));
90 assert_int_equal(2, called);
91 assert_int_equal(4, indexes_count);
92 }
93
94 TEST(add_foreign_key_with_multikey)
95 {
96 key_conf_t key = { { &key_X }, .followed = FOLLOWED_BY_MULTIKEY };
97 assert_success(vle_keys_foreign_add(L"X", &key, /*is_selector=*/0,
98 NORMAL_MODE));
99 assert_true(vle_keys_user_exists(L"X", NORMAL_MODE));
100
101 multikey = 0;
102 assert_int_equal(KEYS_WAIT, vle_keys_exec(L"X"));
103 assert_false(IS_KEYS_RET_CODE(vle_keys_exec(L"X4")));
104 assert_int_equal(1, called);
105 assert_int_equal(L'4', multikey);
106 }
107
74 108 static void static void
75 109 key_X(key_info_t key_info, keys_info_t *keys_info) key_X(key_info_t key_info, keys_info_t *keys_info)
76 110 { {
77 called = 1;
111 ++called;
112 indexes_count = keys_info->count;
113 multikey = key_info.multi;
78 114 } }
79 115
80 116 static void static void
81 117 selector_X(key_info_t key_info, keys_info_t *keys_info) selector_X(key_info_t key_info, keys_info_t *keys_info)
82 118 { {
83 called = 1;
119 ++called;
84 120 keys_info->count = key_info.count; keys_info->count = key_info.count;
85 121 } }
86 122
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master