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 10f855abed34e909e90879c3bcd2d6772a2652fb

Fix rl not moving cursor to the new file
Unlike other operations, CMLO_LINK_REL involves updating `src_buf` to
hold a relative path. However, `dst_name` could be pointing to its
original contents and end up pointing into the middle of the file name
or completely after it. The effect this had was preventing correct
positioning of the cursor and reporting incorrect file name in the undo
message.

The test does not fire without the fix in all configurations because
it depends on how `src_buf` has changed (the part `dst_name` points to
could remain unmodified).
Author: xaizek
Author date (UTC): 2026-03-13 13:36
Committer name: xaizek
Committer date (UTC): 2026-03-13 13:41
Parent(s): 0207ea08ec2f782f097b43c98f10cf263c212b4d
Signing key: 99DC5E4DB05F6BE2
Tree: 3dc21fce5ac32aea423945ab278f833966c76613
File Lines added Lines deleted
ChangeLog 4 0
src/fops_put.c 7 2
tests/misc/normal.c 13 0
File ChangeLog changed (mode: 100644) (index 5cb80b7f5..e8f90fcda)
206 206 Fixed UID/GID occasionally not being formatted as requested (numeric vs. Fixed UID/GID occasionally not being formatted as requested (numeric vs.
207 207 symbolic form) in the UI. Thanks to vuenn. symbolic form) in the UI. Thanks to vuenn.
208 208
209 Fixed rl normal mode key sometimes not moving cursor to the newly inserted
210 link and simultaneously logging partial name in the undo history message,
211 which is merely informative.
212
209 213 0.14-beta to 0.14 (2025-02-08) 0.14-beta to 0.14 (2025-02-08)
210 214
211 215 Improved documentation on zh/zl menu keys a bit. Improved documentation on zh/zl menu keys a bit.
File src/fops_put.c changed (mode: 100644) (index 6dba022de..480145b98)
... ... static int
568 568 put_next(int force) put_next(int force)
569 569 { {
570 570 char *filename; char *filename;
571 const char *dst_name;
572 571 const char *const dst_dir = put_confirm.dst_dir; const char *const dst_dir = put_confirm.dst_dir;
573 572 struct stat src_st; struct stat src_st;
574 573 char src_buf[PATH_MAX + 1], dst_buf[PATH_MAX + 1]; char src_buf[PATH_MAX + 1], dst_buf[PATH_MAX + 1];
 
... ... put_next(int force)
607 606
608 607 copy_str(src_buf, sizeof(src_buf), filename); copy_str(src_buf, sizeof(src_buf), filename);
609 608
610 dst_name = put_confirm.dst_name;
609 const char *dst_name = put_confirm.dst_name;
611 610 if(dst_name == NULL) if(dst_name == NULL)
612 611 { {
613 612 dst_name = fops_get_dst_name(src_buf, from_trash); dst_name = fops_get_dst_name(src_buf, from_trash);
614 613 } }
615 614
615 /* Making a copy to avoid issues when src_buf is modified while dst_name
616 * points into it. */
617 char dst_name_buf[NAME_MAX + 1];
618 copy_str(dst_name_buf, sizeof(dst_name_buf), dst_name);
619 dst_name = dst_name_buf;
620
616 621 build_path(dst_buf, sizeof(dst_buf), dst_dir, dst_name); build_path(dst_buf, sizeof(dst_buf), dst_dir, dst_name);
617 622 chosp(dst_buf); chosp(dst_buf);
618 623
File tests/misc/normal.c changed (mode: 100644) (index 1212a6772..14cca37ee)
... ... TEST(p_P, REPEAT(2))
331 331 make_abs_path(lwin.curr_dir, sizeof(lwin.curr_dir), SANDBOX_PATH, "", cwd); make_abs_path(lwin.curr_dir, sizeof(lwin.curr_dir), SANDBOX_PATH, "", cwd);
332 332 populate_dir_list(&lwin, /*reload=*/0); populate_dir_list(&lwin, /*reload=*/0);
333 333
334 assert_int_equal(0, lwin.list_pos);
335
334 336 ui_sb_msg(""); ui_sb_msg("");
335 337 (void)vle_keys_exec_timed_out(p ? L"p" : L"P"); (void)vle_keys_exec_timed_out(p ? L"p" : L"P");
336 338 assert_success(chdir(cwd)); assert_success(chdir(cwd));
337 339
340 /* Check that the cursor is positioned on the new entry. */
341 assert_int_equal(1, lwin.list_pos);
342
338 343 if(p) if(p)
339 344 { {
340 345 assert_string_equal("1 item copied", ui_sb_last()); assert_string_equal("1 item copied", ui_sb_last());
 
... ... TEST(al_rl, IF(not_windows), REPEAT(2))
501 506 populate_dir_list(&lwin, /*reload=*/0); populate_dir_list(&lwin, /*reload=*/0);
502 507 (void)vle_keys_exec_timed_out(L"yy"); (void)vle_keys_exec_timed_out(L"yy");
503 508
509 create_file(SANDBOX_PATH "/_dummy_first_");
510
504 511 make_abs_path(lwin.curr_dir, sizeof(lwin.curr_dir), SANDBOX_PATH, "", cwd); make_abs_path(lwin.curr_dir, sizeof(lwin.curr_dir), SANDBOX_PATH, "", cwd);
505 512 populate_dir_list(&lwin, /*reload=*/0); populate_dir_list(&lwin, /*reload=*/0);
506 513
514 assert_int_equal(0, lwin.list_pos);
515
507 516 ui_sb_msg(""); ui_sb_msg("");
508 517 (void)vle_keys_exec_timed_out(al ? L"al" : L"rl"); (void)vle_keys_exec_timed_out(al ? L"al" : L"rl");
509 518 assert_success(chdir(cwd)); assert_success(chdir(cwd));
510 519
520 /* Check that the cursor is positioned on the new entry. */
521 assert_int_equal(1, lwin.list_pos);
522
511 523 char target[PATH_MAX + 1]; char target[PATH_MAX + 1];
512 524 assert_success(get_link_target(SANDBOX_PATH "/binary-data", target, assert_success(get_link_target(SANDBOX_PATH "/binary-data", target,
513 525 sizeof(target))); sizeof(target)));
 
... ... TEST(al_rl, IF(not_windows), REPEAT(2))
524 536 assert_false(is_path_absolute(target)); assert_false(is_path_absolute(target));
525 537 } }
526 538
539 remove_file(SANDBOX_PATH "/_dummy_first_");
527 540 remove_file(SANDBOX_PATH "/binary-data"); remove_file(SANDBOX_PATH "/binary-data");
528 541
529 542 regs_reset(); regs_reset();
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