option: Add current directory to &backupdir option

Fixes #3496
This commit is contained in:
ZyX 2015-10-29 00:28:44 +03:00
parent dc8b0c47b1
commit 0bcc2bf126
2 changed files with 7 additions and 3 deletions

View File

@ -901,7 +901,7 @@ A jump table for the options with a short description can be found at |Q_op|.
again not rename the file. again not rename the file.
*'backupdir'* *'bdir'* *'backupdir'* *'bdir'*
'backupdir' 'bdir' string (default "$XDG_DATA_HOME/nvim/backup") 'backupdir' 'bdir' string (default ".,$XDG_DATA_HOME/nvim/backup")
global global
List of directories for the backup file, separated with commas. List of directories for the backup file, separated with commas.
- The backup file will be created in the first directory in the list - The backup file will be created in the first directory in the list

View File

@ -685,9 +685,13 @@ void set_init_1(void)
#endif #endif
false); false);
char *backupdir = stdpaths_user_data_subpath("backup", 0);
const size_t backupdir_len = strlen(backupdir);
backupdir = xrealloc(backupdir, backupdir_len + 3);
memmove(backupdir + 2, backupdir, backupdir_len + 1);
memmove(backupdir, ".,", 2);
set_string_default("viewdir", stdpaths_user_data_subpath("view", 0), true); set_string_default("viewdir", stdpaths_user_data_subpath("view", 0), true);
set_string_default("backupdir", stdpaths_user_data_subpath("backup", 0), set_string_default("backupdir", backupdir, true);
true);
set_string_default("directory", stdpaths_user_data_subpath("swap", 2), true); set_string_default("directory", stdpaths_user_data_subpath("swap", 2), true);
set_string_default("undodir", stdpaths_user_data_subpath("undo", 0), true); set_string_default("undodir", stdpaths_user_data_subpath("undo", 0), true);
// Set default for &runtimepath. All necessary expansions are performed in // Set default for &runtimepath. All necessary expansions are performed in