diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/eval.c | 20 | ||||
| -rw-r--r-- | src/nvim/ex_cmds.c | 8 | ||||
| -rw-r--r-- | src/nvim/ex_docmd.c | 11 | ||||
| -rw-r--r-- | src/nvim/fileio.c | 31 | ||||
| -rw-r--r-- | src/nvim/quickfix.c | 24 | ||||
| -rw-r--r-- | src/nvim/shada.c | 2 | ||||
| -rw-r--r-- | src/nvim/version.c | 4 |
7 files changed, 61 insertions, 39 deletions
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, |