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 cc5b3a01e462d1e893d11953d2039aa945cc31d1

Fix :compare toggling options even without !
Author: xaizek
Author date (UTC): 2023-03-16 17:02
Committer name: xaizek
Committer date (UTC): 2023-03-16 17:02
Parent(s): 6d1196088bd34583dd62b17ec1ea6ddb896fcd0e
Signing key: 99DC5E4DB05F6BE2
Tree: 627d0169bd8467c30fd7eb36d4a4e3ad40f15802
File Lines added Lines deleted
src/cmd_handlers.c 4 5
tests/commands/misc.c 7 0
File src/cmd_handlers.c changed (mode: 100644) (index 60bb01ff6..b1395d1a9)
... ... make_bmark_path(const char path[])
2077 2077 static int static int
2078 2078 compare_cmd(const cmd_info_t *cmd_info) compare_cmd(const cmd_info_t *cmd_info)
2079 2079 { {
2080 int in_compare = cv_compare(curr_view->custom.type);
2081
2082 if(cmd_info->emark && !in_compare)
2080 int is_toggling = cmd_info->emark;
2081 if(is_toggling && !cv_compare(curr_view->custom.type))
2083 2082 { {
2084 2083 ui_sb_err("Toggling requires active compare view"); ui_sb_err("Toggling requires active compare view");
2085 2084 return CMDS_ERR_CUSTOM; return CMDS_ERR_CUSTOM;
 
... ... compare_cmd(const cmd_info_t *cmd_info)
2087 2086
2088 2087 CompareType ct = CT_CONTENTS; CompareType ct = CT_CONTENTS;
2089 2088 ListType lt = LT_ALL; ListType lt = LT_ALL;
2090 int flags = (in_compare ? CF_NONE : CF_GROUP_PATHS);
2089 int flags = (is_toggling ? CF_NONE : CF_GROUP_PATHS);
2091 2090 if(parse_compare_properties(cmd_info, &ct, &lt, &flags) != 0) if(parse_compare_properties(cmd_info, &ct, &lt, &flags) != 0)
2092 2091 { {
2093 2092 return CMDS_ERR_CUSTOM; return CMDS_ERR_CUSTOM;
2094 2093 } }
2095 2094
2096 if(in_compare)
2095 if(is_toggling)
2097 2096 { {
2098 2097 struct cv_data_t *cv = &curr_view->custom; struct cv_data_t *cv = &curr_view->custom;
2099 2098 return (compare_two_panes(cv->diff_cmp_type, cv->diff_list_type, return (compare_two_panes(cv->diff_cmp_type, cv->diff_list_type,
File tests/commands/misc.c changed (mode: 100644) (index ddeca6ccb..e0a369255)
... ... TEST(compare)
350 350 assert_int_equal(CV_REGULAR, lwin.custom.type); assert_int_equal(CV_REGULAR, lwin.custom.type);
351 351 rn_leave(&lwin, /*levels=*/1); rn_leave(&lwin, /*levels=*/1);
352 352
353 /* Can't toggle without !. */
354 (void)cmds_dispatch("compare byname", &lwin, CIT_COMMAND);
355 assert_int_equal(CF_GROUP_PATHS | CF_SHOW, lwin.custom.diff_cmp_flags);
356 (void)cmds_dispatch("compare showdifferent", &lwin, CIT_COMMAND);
357 assert_int_equal(CF_GROUP_PATHS | CF_SHOW, lwin.custom.diff_cmp_flags);
358 rn_leave(&lwin, /*levels=*/1);
359
353 360 /* No toggling. */ /* No toggling. */
354 361 (void)cmds_dispatch("compare! showdifferent", &lwin, CIT_COMMAND); (void)cmds_dispatch("compare! showdifferent", &lwin, CIT_COMMAND);
355 362 assert_string_equal("Toggling requires active compare view", ui_sb_last()); assert_string_equal("Toggling requires active compare view", ui_sb_last());
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