Commit 425fcdb5 authored by Jurica Bradaric's avatar Jurica Bradaric

vim-patch:7.4.1120

Problem:    delete(x, 'rf') fails if a directory is empty. (Lcd)
Solution:   Ignore not finding matches in an empty directory.

https://github.com/vim/vim/commit/336bd622c31e1805495c034e1a8cfadcc0bbabc7
parent 29b737e9
......@@ -1223,7 +1223,7 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
recursive = false;
return (ga.ga_data != NULL) ? OK : FAIL;
return ((flags & EW_EMPTYOK) || ga.ga_data != NULL) ? OK : FAIL;
}
......
......@@ -22,6 +22,7 @@
* is used when executing commands and EW_SILENT for interactive expanding. */
#define EW_ALLLINKS 0x1000 // also links not pointing to existing file
#define EW_DODOT 0x4000 // also files starting with a dot
#define EW_EMPTYOK 0x8000 // no matches is not an error
/// Return value for the comparison of two files. Also @see path_full_compare.
typedef enum file_comparison {
......
......@@ -70,8 +70,8 @@ int delete_recursive(char_u *name)
int file_count;
char_u *exp = vim_strsave(NameBuff);
if (gen_expand_wildcards(1, &exp, &file_count, &files,
EW_DIR | EW_FILE | EW_SILENT
| EW_ALLLINKS | EW_DODOT) == OK) {
EW_DIR | EW_FILE | EW_SILENT | EW_ALLLINKS
| EW_DODOT | EW_EMPTYOK) == OK) {
for (int i = 0; i < file_count; i++) {
if (delete_recursive(files[i]) != 0) {
result = -1;
......
......@@ -244,7 +244,7 @@ static int included_patches[] = {
// 1123,
// 1122 NA
// 1121,
// 1120,
1120,
// 1119,
// 1118,
1117,
......
......@@ -25,6 +25,7 @@ describe('Test for delete()', function()
it('recursive delete', function()
execute("call mkdir('Xdir1')")
execute("call mkdir('Xdir1/subdir')")
execute("call mkdir('Xdir1/empty')")
execute('split Xdir1/Xfile')
execute("call setline(1, ['a', 'b'])")
execute('w')
......@@ -35,6 +36,7 @@ describe('Test for delete()', function()
eq(eval("['a', 'b']"), eval("readfile('Xdir1/Xfile')"))
eq(1, eval("isdirectory('Xdir1/subdir')"))
eq(eval("['a', 'b']"), eval("readfile('Xdir1/subdir/Xfile')"))
eq(1, eval("isdirectory('Xdir1/empty')"))
eq(0, eval("delete('Xdir1', 'rf')"))
eq(0, eval("isdirectory('Xdir1')"))
eq(-1, eval("delete('Xdir1', 'd')"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment