To: vim_dev@googlegroups.com Subject: Patch 8.2.3468 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3468 Problem: Problem with :cd when editing file in non-existent directory. (Yee Cheng Chin) Solution: Prepend the current directory to get the full path. (closes #8903) Files: src/os_unix.c, src/testdir/test_cd.vim *** ../vim-8.2.3467/src/os_unix.c 2021-08-30 20:26:12.860831195 +0100 --- src/os_unix.c 2021-10-03 19:24:20.656125677 +0100 *************** *** 2647,2653 **** { vim_strncpy(buf, fname, p - fname); if (mch_chdir((char *)buf)) ! retval = FAIL; else if (*p == '/') fname = p + 1; else --- 2647,2661 ---- { vim_strncpy(buf, fname, p - fname); if (mch_chdir((char *)buf)) ! { ! // Path does not exist (yet). For a full path fail, ! // will use the path as-is. For a relative path use ! // the current directory and append the file name. ! if (mch_isFullName(fname)) ! retval = FAIL; ! else ! p = NULL; ! } else if (*p == '/') fname = p + 1; else *** ../vim-8.2.3467/src/testdir/test_cd.vim 2021-07-10 16:59:44.679330992 +0100 --- src/testdir/test_cd.vim 2021-10-03 19:22:24.427445390 +0100 *************** *** 208,211 **** --- 208,228 ---- call delete('XComplFile') endfunc + func Test_cd_unknown_dir() + call mkdir('Xa') + cd Xa + call writefile(['text'], 'Xb.txt') + edit Xa/Xb.txt + let first_buf = bufnr() + cd .. + edit + call assert_equal(first_buf, bufnr()) + edit Xa/Xb.txt + call assert_notequal(first_buf, bufnr()) + + bwipe! + exe "bwipe! " .. first_buf + call delete('Xa', 'rf') + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3467/src/version.c 2021-10-03 16:22:01.963285362 +0100 --- src/version.c 2021-10-03 19:03:12.566162614 +0100 *************** *** 759,760 **** --- 759,762 ---- { /* Add new patch number below this line */ + /**/ + 3468, /**/ -- Bare feet magnetize sharp metal objects so they point upward from the floor -- especially in the dark. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///