From c64d6702e5027e494f602094c381dfb9a935608d Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 8 Oct 2018 16:35:40 -0400 Subject: [PATCH 1/3] vim-patch:8.1.0459: Test_executable fails when there is a dog in the system Problem: Test_executable fails when there is a dog in the system. Solution: Rename the dog. (Hirohito Higashi) https://github.com/vim/vim/commit/a05a0d325c7615439f4a42f00682b2ebad43c8d9 --- src/nvim/testdir/test_functions.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 4a27a119f3..b1138bfc96 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -873,7 +873,7 @@ func Test_Executable() call assert_equal(1, executable('win.ini')) elseif has('unix') call assert_equal(1, executable('cat')) - call assert_equal(0, executable('dog')) + call assert_equal(0, executable('nodogshere')) endif endfunc From 573567aef6c62728378394af9767ecf65622ea42 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 8 Oct 2018 17:11:47 -0400 Subject: [PATCH 2/3] vim-patch:8.1.0463: "simalt ~x" in .vimrc blocks swap file prompt Problem: "simalt ~x" in .vimrc blocks swap file prompt. Solution: Flush buffers before prompting. (Yasuhiro Matsumoto, closes vim/vim#3518, closes vim/vim#2192) https://github.com/vim/vim/commit/798184cc67036285a24b38c0bf6668d4d1525548 --- src/nvim/memline.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/nvim/memline.c b/src/nvim/memline.c index ec0238e7c9..712ed0f29f 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -49,6 +49,7 @@ #include "nvim/buffer.h" #include "nvim/cursor.h" #include "nvim/eval.h" +#include "nvim/getchar.h" #include "nvim/fileio.h" #include "nvim/func_attr.h" #include "nvim/main.h" @@ -3358,12 +3359,16 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, choice = do_swapexists(buf, (char_u *) fname); if (choice == 0) { - /* Show info about the existing swap file. */ + // Show info about the existing swap file. attention_message(buf, (char_u *) fname); - /* We don't want a 'q' typed at the more-prompt - * interrupt loading a file. */ + // We don't want a 'q' typed at the more-prompt + // interrupt loading a file. got_int = FALSE; + + // If vimrc has "simalt ~x" we don't want it to + // interfere with the prompt here. + flush_buffers(TRUE); } if (swap_exists_action != SEA_NONE && choice == 0) { From f181efdeaf07a788203b60a2df915118eeb6f0fc Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 8 Oct 2018 21:12:20 -0400 Subject: [PATCH 3/3] vim-patch:8.1.0466: autocmd test fails Problem: Autocmd test fails. Solution: Do call inchar() when flushing typeahead. https://github.com/vim/vim/commit/6a2633b00bb00bcf0d994f08d1c54ace2c221b58 --- src/nvim/getchar.c | 34 +++++++++++++++++++--------------- src/nvim/getchar.h | 7 +++++++ src/nvim/memline.c | 6 +++--- src/nvim/message.c | 2 +- src/nvim/misc1.c | 2 +- 5 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 2eb2df399e..94702a9a3a 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -420,7 +420,7 @@ void typeahead_noflush(int c) * typeahead buffer (used in case of an error). If "flush_typeahead" is true, * flush all typeahead characters (used when interrupted by a CTRL-C). */ -void flush_buffers(int flush_typeahead) +void flush_buffers(flush_buffers_T flush_typeahead) { init_typebuf(); @@ -428,22 +428,24 @@ void flush_buffers(int flush_typeahead) while (read_readbuffers(TRUE) != NUL) { } - if (flush_typeahead) { /* remove all typeahead */ - /* - * We have to get all characters, because we may delete the first part - * of an escape sequence. - * In an xterm we get one char at a time and we have to get them all. - */ - while (inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 10L) != 0) { + if (flush_typeahead == FLUSH_MINIMAL) { + // remove mapped characters at the start only + typebuf.tb_off += typebuf.tb_maplen; + typebuf.tb_len -= typebuf.tb_maplen; + } else { + // remove typeahead + if (flush_typeahead == FLUSH_INPUT) { + // We have to get all characters, because we may delete the first + // part of an escape sequence. In an xterm we get one char at a + // time and we have to get them all. + while (inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 10L) != 0) { + } } typebuf.tb_off = MAXMAPLEN; typebuf.tb_len = 0; // Reset the flag that text received from a client or from feedkeys() // was inserted in the typeahead buffer. typebuf_was_filled = false; - } else { // remove mapped characters at the start only - typebuf.tb_off += typebuf.tb_maplen; - typebuf.tb_len -= typebuf.tb_maplen; } typebuf.tb_maplen = 0; typebuf.tb_silent = 0; @@ -1538,6 +1540,7 @@ int plain_vgetc(void) * Check if a character is available, such that vgetc() will not block. * If the next character is a special character or multi-byte, the returned * character is not valid!. + * Returns NUL if no character is available. */ int vpeekc(void) { @@ -1602,7 +1605,8 @@ vungetc ( /* unget one character (can only be done once!) */ /// KeyTyped is set to TRUE in the case the user typed the key. /// KeyStuffed is TRUE if the character comes from the stuff buffer. /// if "advance" is FALSE (vpeekc()): -/// just look whether there is a character available. +/// Just look whether there is a character available. +/// Return NUL if not. /// /// When `no_mapping` (global) is zero, checks for mappings in the current mode. /// Only returns one byte (of a multi-byte character). @@ -1709,7 +1713,7 @@ static int vgetorpeek(int advance) } else { c = Ctrl_C; } - flush_buffers(true); // flush all typeahead + flush_buffers(FLUSH_INPUT); // flush all typeahead if (advance) { /* Also record this character, it might be needed to @@ -1970,8 +1974,8 @@ static int vgetorpeek(int advance) redrawcmdline(); else setcursor(); - flush_buffers(FALSE); - mapdepth = 0; /* for next one */ + flush_buffers(FLUSH_MINIMAL); + mapdepth = 0; // for next one c = -1; break; } diff --git a/src/nvim/getchar.h b/src/nvim/getchar.h index 38a2e75663..4f548d975a 100644 --- a/src/nvim/getchar.h +++ b/src/nvim/getchar.h @@ -16,6 +16,13 @@ enum { REMAP_SKIP = -3, ///< No remapping for first char. } RemapValues; +// Argument for flush_buffers(). +typedef enum { + FLUSH_MINIMAL, + FLUSH_TYPEAHEAD, // flush current typebuf contents + FLUSH_INPUT // flush typebuf and inchar() input +} flush_buffers_T; + #define KEYLEN_PART_KEY -1 /* keylen value for incomplete key-code */ #define KEYLEN_PART_MAP -2 /* keylen value for incomplete mapping */ #define KEYLEN_REMOVED 9999 /* keylen value for removed sequence */ diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 712ed0f29f..51f99db0de 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -3360,15 +3360,15 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, if (choice == 0) { // Show info about the existing swap file. - attention_message(buf, (char_u *) fname); + attention_message(buf, (char_u *)fname); // We don't want a 'q' typed at the more-prompt // interrupt loading a file. - got_int = FALSE; + got_int = false; // If vimrc has "simalt ~x" we don't want it to // interfere with the prompt here. - flush_buffers(TRUE); + flush_buffers(FLUSH_TYPEAHEAD); } if (swap_exists_action != SEA_NONE && choice == 0) { diff --git a/src/nvim/message.c b/src/nvim/message.c index fc7396d318..1778e0048f 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -552,7 +552,7 @@ int emsg(const char_u *s_) if (p_eb) { beep_flush(); // also includes flush_buffers() } else { - flush_buffers(false); // flush internal buffers + flush_buffers(FLUSH_MINIMAL); // flush internal buffers } did_emsg = true; // flag for DoOneCmd() } diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 2e7fe4d7a9..7e9d68a4b4 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -2548,7 +2548,7 @@ void msgmore(long n) void beep_flush(void) { if (emsg_silent == 0) { - flush_buffers(false); + flush_buffers(FLUSH_MINIMAL); vim_beep(BO_ERROR); } }