diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_cmds.lua | 34 | ||||
-rw-r--r-- | src/nvim/ex_cmds_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 66 | ||||
-rw-r--r-- | src/nvim/getchar.c | 22 | ||||
-rw-r--r-- | src/nvim/globals.h | 3 | ||||
-rw-r--r-- | src/nvim/misc1.c | 15 | ||||
-rw-r--r-- | src/nvim/os/shell.c | 1 | ||||
-rw-r--r-- | src/nvim/version.c | 10 |
8 files changed, 94 insertions, 59 deletions
diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index d5d6d39616..c9dd974d11 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -127,12 +127,12 @@ return { }, { command='buffer', - flags=bit.bor(BANG, RANGE, NOTADR, BUFNAME, BUFUNL, COUNT, EXTRA, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, BUFNAME, BUFUNL, COUNT, EXTRA, EDITCMD, TRLBAR), func='ex_buffer', }, { command='bNext', - flags=bit.bor(BANG, RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bprevious', }, { @@ -162,22 +162,22 @@ return { }, { command='bfirst', - flags=bit.bor(BANG, RANGE, NOTADR, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, EDITCMD, TRLBAR), func='ex_brewind', }, { command='blast', - flags=bit.bor(BANG, RANGE, NOTADR, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, EDITCMD, TRLBAR), func='ex_blast', }, { command='bmodified', - flags=bit.bor(BANG, RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bmodified', }, { command='bnext', - flags=bit.bor(BANG, RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bnext', }, { @@ -187,12 +187,12 @@ return { }, { command='bprevious', - flags=bit.bor(BANG, RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bprevious', }, { command='brewind', - flags=bit.bor(BANG, RANGE, NOTADR, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, EDITCMD, TRLBAR), func='ex_brewind', }, { @@ -1762,47 +1762,47 @@ return { }, { command='sbuffer', - flags=bit.bor(BANG, RANGE, NOTADR, BUFNAME, BUFUNL, COUNT, EXTRA, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, BUFNAME, BUFUNL, COUNT, EXTRA, EDITCMD, TRLBAR), func='ex_buffer', }, { command='sbNext', - flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bprevious', }, { command='sball', - flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_buffer_all', }, { command='sbfirst', - flags=bit.bor(TRLBAR), + flags=bit.bor(EDITCMD, TRLBAR), func='ex_brewind', }, { command='sblast', - flags=bit.bor(TRLBAR), + flags=bit.bor(EDITCMD, TRLBAR), func='ex_blast', }, { command='sbmodified', - flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bmodified', }, { command='sbnext', - flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bnext', }, { command='sbprevious', - flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bprevious', }, { command='sbrewind', - flags=bit.bor(TRLBAR), + flags=bit.bor(EDITCMD, TRLBAR), func='ex_brewind', }, { diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index abf7cc4587..0e13574321 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -88,8 +88,6 @@ typedef struct cmdname { long_u cmd_argt; ///< Relevant flags from the declared above. } CommandDefinition; -#define USER_CMDIDX(idx) ((int)(idx) < 0) - /// Arguments used for Ex commands. struct exarg { char_u *arg; ///< argument of the command diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index e4a8c2735b..359c4b31d1 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -92,6 +92,9 @@ static garray_T ucmds = {0, 0, sizeof(ucmd_T), 4, NULL}; #define USER_CMD(i) (&((ucmd_T *)(ucmds.ga_data))[i]) #define USER_CMD_GA(gap, i) (&((ucmd_T *)((gap)->ga_data))[i]) +/* Wether a command index indicates a user command. */ +# define IS_USER_CMDIDX(idx) ((int)(idx) < 0) + /* Struct for storing a line inside a while/for loop */ typedef struct { char_u *line; /* command line */ @@ -1489,11 +1492,10 @@ static char_u * do_one_cmd(char_u **cmdlinep, goto doend; } - ni = ( - !USER_CMDIDX(ea.cmdidx) && - (cmdnames[ea.cmdidx].cmd_func == ex_ni + ni = (!IS_USER_CMDIDX(ea.cmdidx) + && (cmdnames[ea.cmdidx].cmd_func == ex_ni #ifdef HAVE_EX_SCRIPT_NI - || cmdnames[ea.cmdidx].cmd_func == ex_script_ni + || cmdnames[ea.cmdidx].cmd_func == ex_script_ni #endif )); @@ -1509,8 +1511,9 @@ static char_u * do_one_cmd(char_u **cmdlinep, /* * 5. parse arguments */ - if (!USER_CMDIDX(ea.cmdidx)) + if (!IS_USER_CMDIDX(ea.cmdidx)) { ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; + } if (!ea.skip) { #ifdef HAVE_SANDBOX @@ -1527,8 +1530,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, } if (text_locked() && !(ea.argt & CMDWIN) - && !USER_CMDIDX(ea.cmdidx) - ) { + && !IS_USER_CMDIDX(ea.cmdidx)) { /* Command not allowed when editing the command line. */ if (cmdwin_type != 0) errormsg = (char_u *)_(e_cmdwin); @@ -1542,7 +1544,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, if (!(ea.argt & CMDWIN) && ea.cmdidx != CMD_edit && ea.cmdidx != CMD_checktime - && !USER_CMDIDX(ea.cmdidx) + && !IS_USER_CMDIDX(ea.cmdidx) && curbuf_locked()) goto doend; @@ -1708,17 +1710,15 @@ static char_u * do_one_cmd(char_u **cmdlinep, if ( (ea.argt & REGSTR) && *ea.arg != NUL /* Do not allow register = for user commands */ - && (!USER_CMDIDX(ea.cmdidx) || *ea.arg != '=') + && (!IS_USER_CMDIDX(ea.cmdidx) || *ea.arg != '=') && !((ea.argt & COUNT) && VIM_ISDIGIT(*ea.arg))) { /* check these explicitly for a more specific error message */ if (*ea.arg == '*' || *ea.arg == '+') { errormsg = (char_u *)_(e_invalidreg); goto doend; } - if ( - valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put - && USER_CMDIDX(ea.cmdidx))) - ) { + if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put + && !IS_USER_CMDIDX(ea.cmdidx)))) { ea.regname = *ea.arg++; /* for '=' register: accept the rest of the line as an expression */ if (ea.arg[-1] == '=' && ea.arg[0] != NUL) { @@ -1868,7 +1868,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, * number. Don't do this for a user command. */ if ((ea.argt & BUFNAME) && *ea.arg != NUL && ea.addr_count == 0 - && !USER_CMDIDX(ea.cmdidx) + && !IS_USER_CMDIDX(ea.cmdidx) ) { /* * :bdelete, :bwipeout and :bunload take several arguments, separated @@ -1901,7 +1901,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, ea.cookie = cookie; ea.cstack = cstack; - if (USER_CMDIDX(ea.cmdidx)) { + if (IS_USER_CMDIDX(ea.cmdidx)) { /* * Execute a user-defined command. */ @@ -1949,9 +1949,9 @@ doend: emsg(errormsg); } do_errthrow(cstack, - (ea.cmdidx != CMD_SIZE - && !USER_CMDIDX(ea.cmdidx) - ) ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL); + (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx)) + ? cmdnames[(int)ea.cmdidx].cmd_name + : (char_u *)NULL); if (verbose_save >= 0) p_verbose = verbose_save; @@ -2464,8 +2464,9 @@ set_one_cmd_context ( /* * 5. parse arguments */ - if (!USER_CMDIDX(ea.cmdidx)) + if (!IS_USER_CMDIDX(ea.cmdidx)) { ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; + } arg = skipwhite(p); @@ -3958,13 +3959,17 @@ static void ex_bunload(exarg_T *eap) */ static void ex_buffer(exarg_T *eap) { - if (*eap->arg) + if (*eap->arg) { eap->errmsg = e_trailing; - else { - if (eap->addr_count == 0) /* default is current buffer */ + } else { + if (eap->addr_count == 0) { // default is current buffer goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0); - else + } else { goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2); + } + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } } @@ -3975,6 +3980,9 @@ static void ex_buffer(exarg_T *eap) static void ex_bmodified(exarg_T *eap) { goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } /* @@ -3984,6 +3992,9 @@ static void ex_bmodified(exarg_T *eap) static void ex_bnext(exarg_T *eap) { goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } /* @@ -3995,6 +4006,9 @@ static void ex_bnext(exarg_T *eap) static void ex_bprevious(exarg_T *eap) { goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } /* @@ -4006,6 +4020,9 @@ static void ex_bprevious(exarg_T *eap) static void ex_brewind(exarg_T *eap) { goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } /* @@ -4015,6 +4032,9 @@ static void ex_brewind(exarg_T *eap) static void ex_blast(exarg_T *eap) { goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } int ends_excmd(int c) FUNC_ATTR_CONST diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 882d30388c..d0eebf8fea 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -15,6 +15,7 @@ * mappings and abbreviations */ +#include <assert.h> #include <stdbool.h> #include <string.h> #include <inttypes.h> @@ -3637,11 +3638,26 @@ int check_abbr(int c, char_u *ptr, int col, int mincol) for (; mp; mp->m_next == NULL ? (mp = mp2, mp2 = NULL) : (mp = mp->m_next)) { + int qlen = mp->m_keylen; + char_u *q = mp->m_keys; + int match; + + if (vim_strbyte(mp->m_keys, K_SPECIAL) != NULL) { + /* might have CSI escaped mp->m_keys */ + q = vim_strsave(mp->m_keys); + vim_unescape_csi(q); + qlen = (int)STRLEN(q); + } /* find entries with right mode and keys */ - if ( (mp->m_mode & State) - && mp->m_keylen == len - && !STRNCMP(mp->m_keys, ptr, (size_t)len)) + match = (mp->m_mode & State) + && qlen == len + && !STRNCMP(q, ptr, (size_t)len); + if (q != mp->m_keys) { + free(q); + } + if (match) { break; + } } if (mp != NULL) { /* diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 5f542eec0c..f53a780efe 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -606,9 +606,6 @@ EXTERN int exiting INIT(= FALSE); /* TRUE when planning to exit Vim. Might * still keep on running if there is a changed * buffer. */ -EXTERN int really_exiting INIT(= FALSE); -/* TRUE when we are sure to exit, e.g., after - * a deadly signal */ /* volatile because it is used in signal handler deathtrap(). */ EXTERN volatile int full_screen INIT(= FALSE); /* TRUE when doing full-screen output diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index fc848466c6..4f17f84e11 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -3329,32 +3329,35 @@ void prepare_to_exit(void) */ void preserve_exit(void) { + // 'true' when we are sure to exit, e.g., after a deadly signal + static bool really_exiting = false; + // Prevent repeated calls into this method. if (really_exiting) { exit(2); } - really_exiting = TRUE; + really_exiting = true; prepare_to_exit(); out_str(IObuff); - screen_start(); /* don't know where cursor is now */ + screen_start(); // don't know where cursor is now out_flush(); - ml_close_notmod(); /* close all not-modified buffers */ + ml_close_notmod(); // close all not-modified buffers FOR_ALL_BUFFERS(buf) { if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL) { OUT_STR("Vim: preserving files...\n"); - screen_start(); /* don't know where cursor is now */ + screen_start(); // don't know where cursor is now out_flush(); - ml_sync_all(FALSE, FALSE); /* preserve all swap files */ + ml_sync_all(false, false); // preserve all swap files break; } } - ml_close_all(FALSE); /* close all memfiles, without deleting */ + ml_close_all(false); // close all memfiles, without deleting OUT_STR("Vim: Finished.\n"); diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index c450e24284..d0f8442768 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -268,6 +268,7 @@ static int shell(const char *cmd, static void dynamic_buffer_ensure(DynamicBuffer *buf, size_t desired) { if (buf->cap >= desired) { + assert(buf->data); return; } diff --git a/src/nvim/version.c b/src/nvim/version.c index 6bbb5e6024..8e32dc54ef 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -250,12 +250,12 @@ static int included_patches[] = { 491, //490, 489, - //488, + 488, //487, - //486, - //485, + 486, + 485, //484 NA - //483, + 483, //482 NA //481 NA //480 NA @@ -287,7 +287,7 @@ static int included_patches[] = { //453 NA 452, //451, - //450, + 450, 449, //448 NA 447, |