aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-06-21 09:59:14 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-06-21 12:50:30 -0400
commitbf61885cb45fcced4f5886f336460be4af8a8ba8 (patch)
tree2852806953323960e6bc74ce50203af6b9a8dff0 /src/nvim/ex_cmds.c
parent7ae7da8fb9ab2e23ffc19000798ae27a2dee4e87 (diff)
downloadrneovim-bf61885cb45fcced4f5886f336460be4af8a8ba8.tar.gz
rneovim-bf61885cb45fcced4f5886f336460be4af8a8ba8.tar.bz2
rneovim-bf61885cb45fcced4f5886f336460be4af8a8ba8.zip
vim-patch:8.0.0621: :stag does not respect 'switchbuf'
Problem: The ":stag" command does not respect 'switchbuf'. Solution: Check 'switchbuf' for tag commands that may open a new window. (Ingo Karkat, closes vim/vim#1681) Define macros for the return values of getfile(). https://github.com/vim/vim/commit/8ad80dea089ffeb1a845199c013e9bb4be1cd22e
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r--src/nvim/ex_cmds.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index d58d006dd0..d8aac73b57 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -2006,11 +2006,14 @@ static int check_readonly(int *forceit, buf_T *buf)
/*
* Try to abandon current file and edit a new or existing file.
- * 'fnum' is the number of the file, if zero use ffname/sfname.
+ * "fnum" is the number of the file, if zero use ffname/sfname.
+ * "lnum" is the line number for the cursor in the new file (if non-zero).
*
- * Return 1 for "normal" error, 2 for "not written" error, 0 for success
- * -1 for successfully opening another file.
- * 'lnum' is the line number for the cursor in the new file (if non-zero).
+ * Return:
+ * GETFILE_ERROR for "normal" error,
+ * GETFILE_NOT_WRITTEN for "not written" error,
+ * GETFILE_SAME_FILE for success
+ * GETFILE_OPEN_OTHER for successfully opening another file.
*/
int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum, int forceit)
{
@@ -2018,10 +2021,12 @@ int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum,
int retval;
char_u *free_me = NULL;
- if (text_locked())
- return 1;
- if (curbuf_locked())
- return 1;
+ if (text_locked()) {
+ return GETFILE_ERROR;
+ }
+ if (curbuf_locked()) {
+ return GETFILE_ERROR;
+ }
if (fnum == 0) {
/* make ffname full path, set sfname */
@@ -2042,7 +2047,7 @@ int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum,
if (curbufIsChanged()) {
no_wait_return--;
EMSG(_(e_nowrtmsg));
- retval = 2; // File has been changed.
+ retval = GETFILE_NOT_WRITTEN; // File has been changed.
goto theend;
}
}
@@ -2056,13 +2061,13 @@ int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum,
}
check_cursor_lnum();
beginline(BL_SOL | BL_FIX);
- retval = 0; // it's in the same file
+ retval = GETFILE_SAME_FILE; // it's in the same file
} else if (do_ecmd(fnum, ffname, sfname, NULL, lnum,
(buf_hide(curbuf) ? ECMD_HIDE : 0)
+ (forceit ? ECMD_FORCEIT : 0), curwin) == OK) {
- retval = -1; // opened another file
+ retval = GETFILE_OPEN_OTHER; // opened another file
} else {
- retval = 1; // error encountered
+ retval = GETFILE_ERROR; // error encountered
}
theend: