diff options
32 files changed, 257 insertions, 88 deletions
diff --git a/.travis.yml b/.travis.yml index 1437f7e25b..039a00cce8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,7 @@ env: # http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM - MAKE_CMD="make -j2" # Update PATH for pip. - - PATH="$(python2.7 -c 'import site; print(site.getuserbase())')/bin:$PATH" - # LLVM symbolizer path. - - LLVM_SYMBOLIZER="$(which llvm-symbolizer-3.4)" + - PATH="$(python2.7 -c 'import site; print(site.getuserbase())')/bin:/usr/lib/llvm-symbolizer-3.8/bin:$PATH" # Build directory for Neovim. - BUILD_DIR="$TRAVIS_BUILD_DIR/build" # Build directory for third-party dependencies. @@ -36,9 +34,8 @@ env: -DCMAKE_TOOLCHAIN_FILE=$TRAVIS_BUILD_DIR/cmake/i386-linux-gnu.toolchain.cmake" # Environment variables for Clang sanitizers. - ASAN_OPTIONS="detect_leaks=1:check_initialization_order=1:log_path=$LOG_DIR/asan" - - ASAN_SYMBOLIZER_PATH="$LLVM_SYMBOLIZER" - - TSAN_OPTIONS="external_symbolizer_path=$LLVM_SYMBOLIZER log_path=$LOG_DIR/tsan" - - UBSAN_OPTIONS="log_path=$LOG_DIR/ubsan" + - TSAN_OPTIONS="log_path=$LOG_DIR/tsan" + - UBSAN_OPTIONS="print_stacktrace=1 log_path=$LOG_DIR/ubsan" # Environment variables for Valgrind. - VALGRIND_LOG="$LOG_DIR/valgrind-%p.log" # Cache marker for third-party dependencies cache. @@ -70,10 +67,10 @@ matrix: compiler: gcc-5 -m32 env: BUILD_32BIT=ON - os: linux - compiler: clang + compiler: clang-3.8 env: CLANG_SANITIZER=ASAN_UBSAN - os: linux - compiler: clang + compiler: clang-3.8 env: CLANG_SANITIZER=TSAN - os: osx compiler: clang @@ -96,11 +93,12 @@ addons: # TODO: Remove PPA when Travis gets Python >=3.3. - deadsnakes - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.8 packages: - autoconf - automake - build-essential - - clang-3.4 + - clang-3.8 - cmake - g++-5-multilib - g++-multilib @@ -109,7 +107,7 @@ addons: - gdb - libc6-dev-i386 - libtool - - llvm-3.4-dev + - llvm-3.8-dev - pkg-config - python3.3-dev - unzip diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 9c6cbd5a1a..254cf8b418 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1718,6 +1718,21 @@ v:swapcommand Normal mode command to be executed after a file has been example, when jumping to a tag the value is ":tag tagname\r". For ":edit +cmd file" the value is ":cmd\r". + *v:t_TYPE* *v:t_bool* *t_bool-varialble* +v:t_bool Value of Boolean type. Read-only. See: |type()| + *v:t_dict* *t_dict-varialble* +v:t_dict Value of Dictionary type. Read-only. See: |type()| + *v:t_float* *t_float-varialble* +v:t_float Value of Float type. Read-only. See: |type()| + *v:t_func* *t_func-varialble* +v:t_func Value of Funcref type. Read-only. See: |type()| + *v:t_list* *t_list-varialble* +v:t_list Value of List type. Read-only. See: |type()| + *v:t_number* *t_number-varialble* +v:t_number Value of Number type. Read-only. See: |type()| + *v:t_string* *t_string-varialble* +v:t_string Value of String type. Read-only. See: |type()| + *v:termresponse* *termresponse-variable* v:termresponse The escape sequence returned by the terminal for the |t_RV| termcap entry. It is set when Vim receives an escape sequence diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 49edfda838..f2b75dca2a 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -326,6 +326,7 @@ elseif(CLANG_TSAN) message(STATUS "Enabling Clang thread sanitizer for nvim.") set_property(TARGET nvim APPEND_STRING PROPERTY COMPILE_FLAGS "-DEXITFREE ") set_property(TARGET nvim APPEND_STRING PROPERTY COMPILE_FLAGS "-fsanitize=thread ") + set_property(TARGET nvim APPEND_STRING PROPERTY COMPILE_FLAGS "-fPIE ") set_property(TARGET nvim APPEND_STRING PROPERTY LINK_FLAGS "-fsanitize=thread ") endif() diff --git a/src/nvim/edit.c b/src/nvim/edit.c index dcb772e23c..9d07878f24 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2322,7 +2322,6 @@ static int ins_compl_make_cyclic(void) return count; } - // Set variables that store noselect and noinsert behavior from the // 'completeopt' value. void completeopt_was_set(void) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 750ef4f94f..422fedff1d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -387,6 +387,13 @@ static struct vimvar { VV(VV__NULL_LIST, "_null_list", VAR_LIST, VV_RO), VV(VV__NULL_DICT, "_null_dict", VAR_DICT, VV_RO), VV(VV_VIM_DID_ENTER, "vim_did_enter", VAR_NUMBER, VV_RO), + VV(VV_TYPE_NUMBER, "t_number", VAR_NUMBER, VV_RO), + VV(VV_TYPE_STRING, "t_string", VAR_NUMBER, VV_RO), + VV(VV_TYPE_FUNC, "t_func", VAR_NUMBER, VV_RO), + VV(VV_TYPE_LIST, "t_list", VAR_NUMBER, VV_RO), + VV(VV_TYPE_DICT, "t_dict", VAR_NUMBER, VV_RO), + VV(VV_TYPE_FLOAT, "t_float", VAR_NUMBER, VV_RO), + VV(VV_TYPE_BOOL, "t_bool", VAR_NUMBER, VV_RO), }; #undef VV @@ -400,7 +407,7 @@ static struct vimvar { #define vv_dict vv_di.di_tv.vval.v_dict #define vv_tv vv_di.di_tv -static dictitem_T vimvars_var; /* variable used for v: */ +static dictitem_T vimvars_var; // variable used for v: #define vimvarht vimvardict.dv_hashtab typedef struct { @@ -562,6 +569,14 @@ void eval_init(void) set_vim_var_list(VV_ERRORS, list_alloc()); set_vim_var_nr(VV_SEARCHFORWARD, 1L); set_vim_var_nr(VV_HLSEARCH, 1L); + set_vim_var_nr(VV_COUNT1, 1); + set_vim_var_nr(VV_TYPE_NUMBER, VAR_TYPE_NUMBER); + set_vim_var_nr(VV_TYPE_STRING, VAR_TYPE_STRING); + set_vim_var_nr(VV_TYPE_FUNC, VAR_TYPE_FUNC); + set_vim_var_nr(VV_TYPE_LIST, VAR_TYPE_LIST); + set_vim_var_nr(VV_TYPE_DICT, VAR_TYPE_DICT); + set_vim_var_nr(VV_TYPE_FLOAT, VAR_TYPE_FLOAT); + set_vim_var_nr(VV_TYPE_BOOL, VAR_TYPE_BOOL); set_vim_var_special(VV_FALSE, kSpecialVarFalse); set_vim_var_special(VV_TRUE, kSpecialVarTrue); @@ -10658,7 +10673,7 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (!n) { if (STRNICMP(name, "patch", 5) == 0) { if (name[5] == '-' - && strlen(name) > 11 + && strlen(name) >= 11 && ascii_isdigit(name[6]) && ascii_isdigit(name[8]) && ascii_isdigit(name[10])) { @@ -16800,17 +16815,17 @@ static void f_type(typval_T *argvars, typval_T *rettv, FunPtr fptr) int n = -1; switch (argvars[0].v_type) { - case VAR_NUMBER: n = 0; break; - case VAR_STRING: n = 1; break; - case VAR_FUNC: n = 2; break; - case VAR_LIST: n = 3; break; - case VAR_DICT: n = 4; break; - case VAR_FLOAT: n = 5; break; + case VAR_NUMBER: n = VAR_TYPE_NUMBER; break; + case VAR_STRING: n = VAR_TYPE_STRING; break; + case VAR_FUNC: n = VAR_TYPE_FUNC; break; + case VAR_LIST: n = VAR_TYPE_LIST; break; + case VAR_DICT: n = VAR_TYPE_DICT; break; + case VAR_FLOAT: n = VAR_TYPE_FLOAT; break; case VAR_SPECIAL: { switch (argvars[0].vval.v_special) { case kSpecialVarTrue: case kSpecialVarFalse: { - n = 6; + n = VAR_TYPE_BOOL; break; } case kSpecialVarNull: { diff --git a/src/nvim/eval.h b/src/nvim/eval.h index 1061840816..cc7827b801 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -127,6 +127,13 @@ typedef enum { VV__NULL_LIST, // List with NULL value. For test purposes only. VV__NULL_DICT, // Dictionary with NULL value. For test purposes only. VV_VIM_DID_ENTER, + VV_TYPE_NUMBER, + VV_TYPE_STRING, + VV_TYPE_FUNC, + VV_TYPE_LIST, + VV_TYPE_DICT, + VV_TYPE_FLOAT, + VV_TYPE_BOOL, } VimVarIndex; /// All recognized msgpack types diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index f68663c60c..3b92b3734a 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2552,7 +2552,7 @@ static void add_pack_plugin(char_u *fname, void *cookie) } if (cookie != &APP_ADD_DIR) { - static const char *plugpat = "%s/plugin/*.vim"; // NOLINT + static const char *plugpat = "%s/plugin/**/*.vim"; // NOLINT static const char *ftpat = "%s/ftdetect/*.vim"; // NOLINT size_t len = STRLEN(ffname) + STRLEN(ftpat); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 76dddf874d..23b1a50fc8 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7970,7 +7970,8 @@ static void ex_startinsert(exarg_T *eap) static void ex_stopinsert(exarg_T *eap) { restart_edit = 0; - stop_insert_mode = TRUE; + stop_insert_mode = true; + clearmode(); } /* diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 301a2c1663..f81fb43eaf 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -788,8 +788,28 @@ EXTERN int vr_lines_changed INIT(= 0); /* #Lines changed by "gR" so far */ /// Encoding used when 'fencs' is set to "default" EXTERN char_u *fenc_default INIT(= NULL); -// To speed up BYTELEN() we keep a table with the byte lengths for utf-8 -EXTERN char utf8len_tab[256]; +// To speed up BYTELEN(); keep a lookup table to quickly get the length in +// bytes of a UTF-8 character from the first byte of a UTF-8 string. Bytes +// which are illegal when used as the first byte have a 1. The NUL byte has +// length 1. +EXTERN char utf8len_tab[256] INIT(= { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1, +}); # if defined(USE_ICONV) && defined(DYNAMIC_ICONV) /* Pointers to functions and variables to be loaded at runtime */ diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 7be0be7106..2ecd86974e 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -69,24 +69,6 @@ struct interval { #endif /* - * Lookup table to quickly get the length in bytes of a UTF-8 character from - * the first byte of a UTF-8 string. - * Bytes which are illegal when used as the first byte have a 1. - * The NUL byte has length 1. - */ -char utf8len_tab[256] = -{ - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1, -}; - -/* * Like utf8len_tab above, but using a zero for illegal lead bytes. */ static uint8_t utf8len_tab_zero[256] = diff --git a/src/nvim/message.c b/src/nvim/message.c index 1de2347b12..f9cfc49197 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -19,6 +19,7 @@ #include "nvim/fileio.h" #include "nvim/func_attr.h" #include "nvim/getchar.h" +#include "nvim/main.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/misc1.h" @@ -581,6 +582,24 @@ bool emsgf(const char *const fmt, ...) return emsg(IObuff); } +static void msg_emsgf_event(void **argv) +{ + char *s = argv[0]; + (void)emsg((char_u *)s); + xfree(s); +} + +void msg_schedule_emsgf(const char *const fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vim_vsnprintf((char *)IObuff, IOSIZE, fmt, ap, NULL); + va_end(ap); + + char *s = xstrdup((char *)IObuff); + loop_schedule(&main_loop, event_create(1, msg_emsgf_event, 1, s)); +} + /* * Like msg(), but truncate to a single line if p_shm contains 't', or when * "force" is TRUE. This truncates in another way as for normal messages. diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index c3a909692f..5137b375f0 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -125,7 +125,7 @@ bool msgpack_rpc_to_object(const msgpack_object *const obj, Object *const arg) dest = conv(((String) { \ .size = obj->via.attr.size, \ .data = (obj->via.attr.ptr == NULL || obj->via.attr.size == 0 \ - ? NULL \ + ? xmemdupz("", 0) \ : xmemdupz(obj->via.attr.ptr, obj->via.attr.size)), \ })); \ break; \ @@ -326,7 +326,9 @@ void msgpack_rpc_from_string(String result, msgpack_packer *res) FUNC_ATTR_NONNULL_ARG(2) { msgpack_pack_str(res, result.size); - msgpack_pack_str_body(res, result.data, result.size); + if (result.size > 0) { + msgpack_pack_str_body(res, result.data, result.size); + } } typedef struct { diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 18ee008d66..9e6effd21b 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -548,8 +548,8 @@ static void shell_write_cb(Stream *stream, void *data, int status) if (status) { // Can happen if system() tries to send input to a shell command that was // backgrounded (:call system("cat - &", "foo")). #3529 #5241 - EMSG2(_("E5677: Error writing input to shell-command: %s"), - uv_err_name(status)); + msg_schedule_emsgf(_("E5677: Error writing input to shell-command: %s"), + uv_err_name(status)); } if (stream->closed) { // Process may have exited before this write. ELOG("stream was already closed"); diff --git a/src/nvim/rbuffer.c b/src/nvim/rbuffer.c index a2cc432eca..111af0d0fb 100644 --- a/src/nvim/rbuffer.c +++ b/src/nvim/rbuffer.c @@ -18,7 +18,7 @@ RBuffer *rbuffer_new(size_t capacity) capacity = 0x10000; } - RBuffer *rv = xmalloc(sizeof(RBuffer) + capacity); + RBuffer *rv = xcalloc(1, sizeof(RBuffer) + capacity); rv->full_cb = rv->nonfull_cb = NULL; rv->data = NULL; rv->size = 0; @@ -78,7 +78,7 @@ void rbuffer_reset(RBuffer *buf) FUNC_ATTR_NONNULL_ALL size_t temp_size; if ((temp_size = rbuffer_size(buf))) { if (buf->temp == NULL) { - buf->temp = xmalloc(rbuffer_capacity(buf)); + buf->temp = xcalloc(1, rbuffer_capacity(buf)); } rbuffer_read(buf, buf->temp, buf->size); } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index cee3c62f43..5bf743c4df 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -6827,12 +6827,18 @@ void unshowmode(bool force) if (!redrawing() || (!force && char_avail() && !KeyTyped)) { redraw_cmdline = true; // delete mode later } else { + clearmode(); + } +} + +// Clear the mode message. +void clearmode(void) +{ msg_pos_mode(); if (Recording) { recording_mode(hl_attr(HLF_CM)); } msg_clr_eos(); - } } static void recording_mode(int attr) diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 01c0807d82..d902079739 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1575,7 +1575,9 @@ static char *shada_filename(const char *file) do { \ const String s_ = (s); \ msgpack_pack_bin(spacker, s_.size); \ - msgpack_pack_bin_body(spacker, s_.data, s_.size); \ + if (s_.size > 0) { \ + msgpack_pack_bin_body(spacker, s_.data, s_.size); \ + } \ } while (0) /// Write single ShaDa entry diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index e57965ac2c..cd37bde3cb 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -392,7 +392,9 @@ void syntax_start(win_T *wp, linenr_T lnum) * Also do this when a change was made, the current state may be invalid * then. */ - if (syn_block != wp->w_s || changedtick != syn_buf->b_changedtick) { + if (syn_block != wp->w_s + || syn_buf != wp->w_buffer + || changedtick != syn_buf->b_changedtick) { invalidate_current_state(); syn_buf = wp->w_buffer; syn_block = wp->w_s; diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 67e7c97905..c6e9c26c57 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -32,6 +32,7 @@ SCRIPTS := \ # Keep test_alot*.res as the last one, sort the others. NEW_TESTS = \ test_cscope.res \ + test_cmdline.res \ test_hardcopy.res \ test_help_tagjump.res \ test_history.res \ diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index e2d1e67a22..d1857565a4 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -42,6 +42,14 @@ endif " This also enables use of line continuation. set viminfo+=nviminfo +" Use utf-8 or latin1 be default, instead of whatever the system default +" happens to be. Individual tests can overrule this at the top of the file. +if has('multi_byte') + set encoding=utf-8 +else + set encoding=latin1 +endif + " Avoid stopping at the "hit enter" prompt set nomore @@ -51,6 +59,9 @@ lang mess C " Always use forward slashes. set shellslash +" Make sure $HOME does not get read or written. +let $HOME = '/does/not/exist' + function RunTheTest(test) echo 'Executing ' . a:test if exists("*SetUp") @@ -123,6 +134,9 @@ for s:test in sort(s:tests) endfor +" Don't write viminfo on exit. +set viminfo= + if s:fail == 0 " Success, create the .res file so that make knows it's done. exe 'split ' . fnamemodify(g:testname, ':r') . '.res' diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index 156604051d..4e8cd54ce3 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -8,7 +8,6 @@ source test_ex_undo.vim source test_expr.vim source test_expr_utf8.vim source test_feedkeys.vim -source test_cmdline.vim source test_menu.vim source test_options.vim source test_popup.vim diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim index 7ea4ebc7df..83b5e66fe0 100644 --- a/src/nvim/testdir/test_expr.vim +++ b/src/nvim/testdir/test_expr.vim @@ -1,5 +1,20 @@ " Tests for expressions. +func Test_version() + call assert_true(has('patch-7.4.001')) + call assert_true(has('patch-7.4.01')) + call assert_true(has('patch-7.4.1')) + call assert_true(has('patch-6.9.999')) + call assert_true(has('patch-7.1.999')) + call assert_true(has('patch-7.4.123')) + + call assert_false(has('patch-7')) + call assert_false(has('patch-7.4')) + call assert_false(has('patch-7.4.')) + call assert_false(has('patch-9.1.0')) + call assert_false(has('patch-9.9.1')) +endfunc + func Test_strgetchar() call assert_equal(char2nr('a'), strgetchar('axb', 0)) call assert_equal(char2nr('x'), strgetchar('axb', 1)) diff --git a/src/nvim/testdir/test_expr_utf8.vim b/src/nvim/testdir/test_expr_utf8.vim index 7bdcb4f65f..9ea6d8872b 100644 --- a/src/nvim/testdir/test_expr_utf8.vim +++ b/src/nvim/testdir/test_expr_utf8.vim @@ -2,7 +2,6 @@ if !has('multi_byte') finish endif -scriptencoding utf-8 func Test_strgetchar_utf8() call assert_equal(char2nr('á'), strgetchar('áxb', 0)) diff --git a/src/nvim/testdir/test_regexp_utf8.vim b/src/nvim/testdir/test_regexp_utf8.vim index 38f9ed41d5..ecb03a0f8c 100644 --- a/src/nvim/testdir/test_regexp_utf8.vim +++ b/src/nvim/testdir/test_regexp_utf8.vim @@ -1,5 +1,4 @@ " Tests for regexp in utf8 encoding -scriptencoding utf-8 func s:equivalence_test() let str = "AÀÁÂÃÄÅĀĂĄǍǞǠẢ BḂḆ CÇĆĈĊČ DĎĐḊḎḐ EÈÉÊËĒĔĖĘĚẺẼ FḞ GĜĞĠĢǤǦǴḠ HĤĦḢḦḨ IÌÍÎÏĨĪĬĮİǏỈ JĴ KĶǨḰḴ LĹĻĽĿŁḺ MḾṀ NÑŃŅŇṄṈ OÒÓÔÕÖØŌŎŐƠǑǪǬỎ PṔṖ Q RŔŖŘṘṞ SŚŜŞŠṠ TŢŤŦṪṮ UÙÚÛÜŨŪŬŮŰŲƯǓỦ VṼ WŴẀẂẄẆ XẊẌ YÝŶŸẎỲỶỸ ZŹŻŽƵẐẔ aàáâãäåāăąǎǟǡả bḃḇ cçćĉċč dďđḋḏḑ eèéêëēĕėęěẻẽ fḟ gĝğġģǥǧǵḡ hĥħḣḧḩẖ iìíîïĩīĭįǐỉ jĵǰ kķǩḱḵ lĺļľŀłḻ mḿṁ nñńņňʼnṅṉ oòóôõöøōŏőơǒǫǭỏ pṕṗ q rŕŗřṙṟ sśŝşšṡ tţťŧṫṯẗ uùúûüũūŭůűųưǔủ vṽ wŵẁẃẅẇẘ xẋẍ yýÿŷẏẙỳỷỹ zźżžƶẑẕ" diff --git a/src/nvim/testdir/test_viml.vim b/src/nvim/testdir/test_viml.vim index c39c5e6b28..a11d62f5cf 100644 --- a/src/nvim/testdir/test_viml.vim +++ b/src/nvim/testdir/test_viml.vim @@ -949,6 +949,14 @@ func Test_type() call assert_equal(6, type(v:false)) call assert_equal(6, type(v:true)) call assert_equal(7, type(v:null)) + call assert_equal(v:t_number, type(0)) + call assert_equal(v:t_string, type("")) + call assert_equal(v:t_func, type(function("tr"))) + call assert_equal(v:t_list, type([])) + call assert_equal(v:t_dict, type({})) + call assert_equal(v:t_float, type(0.0)) + call assert_equal(v:t_bool, type(v:false)) + call assert_equal(v:t_bool, type(v:true)) endfunc "------------------------------------------------------------------------------- diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 83bae967e2..cf0e535937 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -2,7 +2,6 @@ if !has('multi_byte') finish endif -scriptencoding utf-8 if !has('visual') finish diff --git a/src/nvim/ui.c b/src/nvim/ui.c index eb500414a7..549ed8aa7d 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -177,14 +177,14 @@ void ui_refresh(void) pum_set_external(pum_external); } -static void ui_refresh_handler(void **argv) +static void ui_refresh_event(void **argv) { ui_refresh(); } void ui_schedule_refresh(void) { - loop_schedule(&main_loop, event_create(1, ui_refresh_handler, 0)); + loop_schedule(&main_loop, event_create(1, ui_refresh_event, 0)); } void ui_resize(int new_width, int new_height) diff --git a/src/nvim/version.c b/src/nvim/version.c index 3499c2e1b9..11c8a72b2a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -131,7 +131,7 @@ static int included_patches[] = { // 2314, // 2313, 2312, - // 2311, + // 2311 NA // 2310 NA 2309, // 2308 NA @@ -356,7 +356,7 @@ static int included_patches[] = { // 2089 NA // 2088, // 2087, - // 2086, + 2086, // 2085, // 2084, // 2083, @@ -371,7 +371,7 @@ static int included_patches[] = { // 2074, // 2073, // 2072, - // 2071, + 2071, // 2070 NA // 2069, // 2068, @@ -435,7 +435,7 @@ static int included_patches[] = { // 2010, // 2009, // 2008, - // 2007, + 2007, // 2006, // 2005, // 2004 NA @@ -514,12 +514,12 @@ static int included_patches[] = { // 1931 NA // 1930 NA // 1929 NA - // 1928, + 1928, // 1927 NA // 1926 NA // 1925 NA // 1924 NA - // 1923, + 1923, // 1922 NA // 1921 NA // 1920 NA @@ -734,7 +734,7 @@ static int included_patches[] = { // 1713 NA 1712, // 1711, - // 1710, + // 1710 NA // 1709 NA // 1708, // 1707, @@ -745,20 +745,20 @@ static int included_patches[] = { // 1702, 1701, 1700, - // 1699, + 1699, // 1698 NA 1697, - // 1696, + 1696, 1695, // 1694 NA // 1693 NA // 1692, - // 1691, + 1691, // 1690 NA // 1689 NA // 1688 NA // 1687 NA - // 1686, + 1686, // 1685, // 1684 NA // 1683 NA @@ -784,7 +784,7 @@ static int included_patches[] = { 1663, // 1662 NA // 1661 NA - // 1660, + 1660, // 1659 NA 1658, // 1657 NA diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 32eba55c18..8271abda8d 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -123,6 +123,14 @@ Error: configure did not run properly.Check auto/config.log. #define FAIL 0 #define NOTDONE 2 /* not OK or FAIL but skipped */ +// Type values for type(). +#define VAR_TYPE_NUMBER 0 +#define VAR_TYPE_STRING 1 +#define VAR_TYPE_FUNC 2 +#define VAR_TYPE_LIST 3 +#define VAR_TYPE_DICT 4 +#define VAR_TYPE_FLOAT 5 +#define VAR_TYPE_BOOL 6 /* * values for xp_context when doing command line completion diff --git a/test/functional/legacy/060_exists_and_has_functions_spec.lua b/test/functional/legacy/060_exists_and_has_functions_spec.lua index cbd857c524..3e99f6df57 100644 --- a/test/functional/legacy/060_exists_and_has_functions_spec.lua +++ b/test/functional/legacy/060_exists_and_has_functions_spec.lua @@ -638,15 +638,6 @@ describe('exists() and has() functions', function() call TestExists() - function TestHas() - redir >> test.out - for pl in ['6.9.999', '7.1.999', '7.4.123', '9.1.0', '9.9.1'] - echo 'has patch ' . pl . ': ' . has('patch-' . pl) - endfor - redir END - endfunc - call TestHas() - edit! test.out set ff=unix ]=]) @@ -858,12 +849,7 @@ describe('exists() and has() functions', function() OK g:footest#x = 1 footest#F() 0 - UndefFun() 0 - has patch 6.9.999: 1 - has patch 7.1.999: 1 - has patch 7.4.123: 1 - has patch 9.1.0: 0 - has patch 9.9.1: 0]]) + UndefFun() 0]]) end) end) diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 68bdbf5257..2d851819e3 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -27,7 +27,7 @@ describe('packadd', function() endfunc func Test_packadd() - call mkdir(s:plugdir . '/plugin', 'p') + call mkdir(s:plugdir . '/plugin/also', 'p') call mkdir(s:plugdir . '/ftdetect', 'p') call mkdir(s:plugdir . '/after', 'p') set rtp& @@ -38,6 +38,10 @@ describe('packadd', function() call setline(1, 'let g:plugin_works = 42') wq + exe 'split ' . s:plugdir . '/plugin/also/loaded.vim' + call setline(1, 'let g:plugin_also_works = 77') + wq + exe 'split ' . s:plugdir . '/ftdetect/test.vim' call setline(1, 'let g:ftdetect_works = 17') wq @@ -45,6 +49,7 @@ describe('packadd', function() packadd mytest call assert_true(42, g:plugin_works) + call assert_equal(77, g:plugin_also_works) call assert_true(17, g:ftdetect_works) call assert_true(len(&rtp) > len(rtp)) call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 96324bfac5..6c1a1788ce 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -170,9 +170,9 @@ function Screen.new(width, height) update_menu = false, visual_bell = false, suspended = false, + mode = 'normal', _default_attr_ids = nil, _default_attr_ignore = nil, - _mode = 'normal', _mouse_enabled = true, _attrs = {}, _cursor = { @@ -375,7 +375,7 @@ end function Screen:_handle_mode_change(mode) assert(mode == 'insert' or mode == 'replace' or mode == 'normal') - self._mode = mode + self.mode = mode end function Screen:_handle_set_scroll_region(top, bot, left, right) @@ -549,7 +549,7 @@ function Screen:print_snapshot(attrs, ignore) if attrs == nil then attrs = {} if self._default_attr_ids ~= nil then - for i, a in ipairs(self._default_attr_ids) do + for i, a in pairs(self._default_attr_ids) do attrs[i] = a end end diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 2b44b92336..593b6dd763 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.clear local feed, execute = helpers.feed, helpers.execute local insert = helpers.insert +local eq = helpers.eq if helpers.pending_win32(pending) then return end @@ -576,4 +577,70 @@ describe('Screen', function() ]]) end) end) + + describe('mode change', function() + before_each(function() + screen:try_resize(25, 5) + end) + + it('works in normal mode', function() + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]],nil,nil,function () + eq("normal", screen.mode) + end) + end) + + it('works in insert mode', function() + feed('i') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {2:-- INSERT --} | + ]],nil,nil,function () + eq("insert", screen.mode) + end) + + feed('word<esc>') + screen:expect([[ + wor^d | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]], nil, nil, function () + eq("normal", screen.mode) + end) + end) + + it('works in replace mode', function() + feed('R') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {2:-- REPLACE --} | + ]], nil, nil, function () + eq("replace", screen.mode) + end) + + feed('word<esc>') + screen:expect([[ + wor^d | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]], nil, nil, function () + eq("normal", screen.mode) + end) + end) + end) end) |