aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/quickfix.txt18
-rw-r--r--src/nvim/eval.c20
-rw-r--r--src/nvim/ex_cmds.c8
-rw-r--r--src/nvim/ex_docmd.c11
-rw-r--r--src/nvim/fileio.c31
-rw-r--r--src/nvim/quickfix.c24
-rw-r--r--src/nvim/shada.c2
-rw-r--r--src/nvim/version.c4
-rw-r--r--test/functional/ex_cmds/cd_spec.lua20
-rw-r--r--test/functional/shada/helpers.lua8
-rw-r--r--test/functional/shada/shada_spec.lua19
11 files changed, 120 insertions, 45 deletions
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 3b54faf18e..e2a44541ae 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -1,4 +1,4 @@
-*quickfix.txt* For Vim version 7.4. Last change: 2016 Mar 19
+*quickfix.txt* For Vim version 7.4. Last change: 2016 Jul 01
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -259,9 +259,23 @@ location list command, it will be aborted.
The 'switchbuf' settings are respected when jumping
to a buffer.
+:cl[ist] +{count} List the current and next {count} valid errors. This
+ is similar to ":clist from from+count", where "from"
+ is the current error position.
+
:cl[ist]! [from] [, [to]]
List all errors.
+:cl[ist]! +{count} List the current and next {count} error lines. This
+ is useful to see unrecognized lines after the current
+ one. For example, if ":clist" shows:
+ 8384 testje.java:252: error: cannot find symbol ~
+ Then using ":cl! +3" shows the reason:
+ 8384 testje.java:252: error: cannot find symbol ~
+ 8385: ZexitCode = Fmainx(); ~
+ 8386: ^ ~
+ 8387: symbol: method Fmainx() ~
+
*:lli* *:llist*
:lli[st] [from] [, [to]]
Same as ":clist", except the location list for the
@@ -306,7 +320,7 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
etc.
< When the current file can't be |abandon|ed and the [!]
is not present, the command fails.
- When an error is detected excecution stops.
+ When an error is detected execution stops.
The last buffer (or where an error occurred) becomes
the current buffer.
{cmd} can contain '|' to concatenate several commands.
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index bfe4707dab..211419f7a6 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -9776,26 +9776,20 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (from) {
break;
}
- case kCdScopeTab: // FALLTHROUGH
+ case kCdScopeTab: // FALLTHROUGH
assert(tp);
from = tp->localdir;
if (from) {
break;
}
- case kCdScopeGlobal: // FALLTHROUGH
- // The `globaldir` variable is not always set.
- if (globaldir) {
+ case kCdScopeGlobal: // FALLTHROUGH
+ if (globaldir) { // `globaldir` is not always set.
from = globaldir;
- } else {
- // We have to copy the OS path directly into output string.
- if (os_dirname(cwd, MAXPATHL) == FAIL) {
- EMSG(_("E41: Could not display path."));
- goto end;
- }
+ } else if (os_dirname(cwd, MAXPATHL) == FAIL) { // Get the OS CWD.
+ from = (char_u *)""; // Return empty string on failure.
}
break;
- case kCdScopeInvalid:
- // We should never get here
+ case kCdScopeInvalid: // We should never get here
assert(false);
}
@@ -9807,7 +9801,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(rettv->vval.v_string);
#endif
-end:
+
xfree(cwd);
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 3dcd9a9116..9cf53f0d73 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1711,11 +1711,11 @@ int do_write(exarg_T *eap)
goto theend;
}
- /* If 'filetype' was empty try detecting it now. */
+ // If 'filetype' was empty try detecting it now.
if (*curbuf->b_p_ft == NUL) {
- if (au_has_group((char_u *)"filetypedetect"))
- (void)do_doautocmd((char_u *)"filetypedetect BufRead",
- TRUE);
+ if (au_has_group((char_u *)"filetypedetect")) {
+ (void)do_doautocmd((char_u *)"filetypedetect BufRead", true, NULL);
+ }
do_modelines(0);
}
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 967c4fc5b4..e3ca177029 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -4364,12 +4364,15 @@ static void ex_autocmd(exarg_T *eap)
*/
static void ex_doautocmd(exarg_T *eap)
{
- char_u *arg = eap->arg;
+ char_u *arg = eap->arg;
int call_do_modelines = check_nomodeline(&arg);
+ bool did_aucmd;
- (void)do_doautocmd(arg, TRUE);
- if (call_do_modelines) /* Only when there is no <nomodeline>. */
+ (void)do_doautocmd(arg, true, &did_aucmd);
+ // Only when there is no <nomodeline>.
+ if (call_do_modelines && did_aucmd) {
do_modelines(0);
+ }
}
/*
@@ -9464,7 +9467,7 @@ static void ex_filetype(exarg_T *eap)
}
}
if (*arg == 'd') {
- (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE);
+ (void)do_doautocmd((char_u *)"filetypedetect BufRead", true, NULL);
do_modelines(0);
}
} else if (STRCMP(arg, "off") == 0) {
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index e0b6ae1215..89e5fdb776 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -3773,8 +3773,9 @@ static int set_rw_fname(char_u *fname, char_u *sfname)
/* Do filetype detection now if 'filetype' is empty. */
if (*curbuf->b_p_ft == NUL) {
- if (au_has_group((char_u *)"filetypedetect"))
- (void)do_doautocmd((char_u *)"filetypedetect BufRead", FALSE);
+ if (au_has_group((char_u *)"filetypedetect")) {
+ (void)do_doautocmd((char_u *)"filetypedetect BufRead", false, NULL);
+ }
do_modelines(0);
}
@@ -6058,13 +6059,18 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
int
do_doautocmd (
char_u *arg,
- int do_msg /* give message for no matching autocmds? */
+ int do_msg, // give message for no matching autocmds?
+ bool *did_something
)
{
char_u *fname;
int nothing_done = TRUE;
int group;
+ if (did_something != NULL) {
+ *did_something = false;
+ }
+
/*
* Check for a legal group name. If not, use AUGROUP_ALL.
*/
@@ -6093,8 +6099,12 @@ do_doautocmd (
fname, NULL, TRUE, group, curbuf, NULL))
nothing_done = FALSE;
- if (nothing_done && do_msg)
+ if (nothing_done && do_msg) {
MSG(_("No matching autocommands"));
+ }
+ if (did_something != NULL) {
+ *did_something = !nothing_done;
+ }
return aborting() ? FAIL : OK;
}
@@ -6123,13 +6133,14 @@ void ex_doautoall(exarg_T *eap)
/* find a window for this buffer and save some values */
aucmd_prepbuf(&aco, buf);
- /* execute the autocommands for this buffer */
- retval = do_doautocmd(arg, FALSE);
+ bool did_aucmd;
+ // execute the autocommands for this buffer
+ retval = do_doautocmd(arg, false, &did_aucmd);
- if (call_do_modelines) {
- /* Execute the modeline settings, but don't set window-local
- * options if we are using the current window for another
- * buffer. */
+ if (call_do_modelines && did_aucmd) {
+ // Execute the modeline settings, but don't set window-local
+ // options if we are using the current window for another
+ // buffer.
do_modelines(curwin == aucmd_win ? OPT_NOWIN : 0);
}
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 20bd0a62b8..2a3cdfa790 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1732,15 +1732,29 @@ void qf_list(exarg_T *eap)
EMSG(_(e_quickfix));
return;
}
+
+ bool plus = false;
+ if (*arg == '+') {
+ arg++;
+ plus = true;
+ }
if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL) {
EMSG(_(e_trailing));
return;
}
- i = qi->qf_lists[qi->qf_curlist].qf_count;
- if (idx1 < 0)
- idx1 = (-idx1 > i) ? 0 : idx1 + i + 1;
- if (idx2 < 0)
- idx2 = (-idx2 > i) ? 0 : idx2 + i + 1;
+ if (plus) {
+ i = qi->qf_lists[qi->qf_curlist].qf_index;
+ idx2 = i + idx1;
+ idx1 = i;
+ } else {
+ i = qi->qf_lists[qi->qf_curlist].qf_count;
+ if (idx1 < 0) {
+ idx1 = (-idx1 > i) ? 0 : idx1 + i + 1;
+ }
+ if (idx2 < 0) {
+ idx2 = (-idx2 > i) ? 0 : idx2 + i + 1;
+ }
+ }
if (qi->qf_lists[qi->qf_curlist].qf_nonevalid)
all = TRUE;
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index fe62f06e59..d2d0d503b9 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -2976,7 +2976,7 @@ shada_write_file_nomerge: {}
if (sd_writer.cookie == NULL) {
xfree(fname);
xfree(tempname);
- if (sd_reader.close != NULL) {
+ if (sd_reader.cookie != NULL) {
sd_reader.close(&sd_reader);
}
return FAIL;
diff --git a/src/nvim/version.c b/src/nvim/version.c
index d37eec1c28..95ca3f066f 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -305,7 +305,7 @@ static int included_patches[] = {
// 1974 NA
1973,
// 1972,
- // 1971,
+ 1971,
// 1970,
// 1969 NA
// 1968,
@@ -363,7 +363,7 @@ static int included_patches[] = {
// 1916 NA
// 1915 NA
// 1914,
- // 1913,
+ 1913,
// 1912,
// 1911,
// 1910,
diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua
index 74432dbe00..85e1a5c5d5 100644
--- a/test/functional/ex_cmds/cd_spec.lua
+++ b/test/functional/ex_cmds/cd_spec.lua
@@ -269,3 +269,23 @@ for _, cmd in ipairs {'getcwd', 'haslocaldir'} do
end)
end
+describe("getcwd()", function ()
+ local temp_dir = "Xtest-functional-ex_cmds-cd_spec.temp"
+ before_each(function()
+ clear()
+ lfs.mkdir(temp_dir)
+ end)
+
+ after_each(function()
+ helpers.rmdir(temp_dir)
+ end)
+
+ it("returns empty string if working directory does not exist", function()
+ execute("cd " .. temp_dir)
+ helpers.wait()
+ helpers.rmdir(temp_dir)
+ eq("", helpers.eval("getcwd()"))
+ end)
+end)
+
+
diff --git a/test/functional/shada/helpers.lua b/test/functional/shada/helpers.lua
index cde555f0a7..8e2c0cc1f6 100644
--- a/test/functional/shada/helpers.lua
+++ b/test/functional/shada/helpers.lua
@@ -8,8 +8,8 @@ local mpack = require('mpack')
local tmpname = helpers.tmpname()
local additional_cmd = ''
-local function nvim_argv()
- local argv = {nvim_prog, '-u', 'NONE', '-i', tmpname, '-N',
+local function nvim_argv(shada_file)
+ local argv = {nvim_prog, '-u', 'NONE', '-i', shada_file or tmpname, '-N',
'--cmd', 'set shortmess+=I background=light noswapfile',
'--cmd', additional_cmd,
'--embed'}
@@ -20,8 +20,8 @@ local function nvim_argv()
end
end
-local reset = function()
- set_session(spawn(nvim_argv()))
+local reset = function(shada_file)
+ set_session(spawn(nvim_argv(shada_file)))
meths.set_var('tmpname', tmpname)
end
diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua
index f6f3a8f826..f845f6f93b 100644
--- a/test/functional/shada/shada_spec.lua
+++ b/test/functional/shada/shada_spec.lua
@@ -5,6 +5,7 @@ local meths, nvim_command, funcs, eq =
local write_file, spawn, set_session, nvim_prog, exc_exec =
helpers.write_file, helpers.spawn, helpers.set_session, helpers.nvim_prog,
helpers.exc_exec
+
local lfs = require('lfs')
local paths = require('test.config.paths')
@@ -14,10 +15,14 @@ local shada_helpers = require('test.functional.shada.helpers')
local reset, clear, get_shada_rw =
shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
local read_shada_file = shada_helpers.read_shada_file
+local set_additional_cmd = shada_helpers.set_additional_cmd
local wshada, _, shada_fname, clean =
get_shada_rw('Xtest-functional-shada-shada.shada')
+local dirname = 'Xtest-functional-shada-shada.d'
+local dirshada = dirname .. '/main.shada'
+
if helpers.pending_win32(pending) then return end
describe('ShaDa support code', function()
@@ -25,6 +30,7 @@ describe('ShaDa support code', function()
after_each(function()
clear()
clean()
+ lfs.rmdir(dirname)
end)
it('preserves `s` item size limit with unknown entries', function()
@@ -232,4 +238,17 @@ describe('ShaDa support code', function()
eq('', meths.get_option('viminfo'))
eq('', meths.get_option('shada'))
end)
+
+ it('does not crash when ShaDa file directory is not writable', function()
+ funcs.mkdir(dirname, '', 0)
+ eq(0, funcs.filewritable(dirname))
+ set_additional_cmd('set shada=')
+ reset(dirshada)
+ meths.set_option('shada', '\'10')
+ eq('Vim(wshada):E886: System error while opening ShaDa file '
+ .. 'Xtest-functional-shada-shada.d/main.shada for reading to merge '
+ .. 'before writing it: permission denied',
+ exc_exec('wshada'))
+ meths.set_option('shada', '')
+ end)
end)