diff options
-rw-r--r-- | .github/workflows/ci.yml | 12 | ||||
-rw-r--r-- | ci/common/suite.sh | 40 | ||||
-rw-r--r-- | ci/common/test.sh | 29 | ||||
-rwxr-xr-x | ci/run_lint.sh | 39 | ||||
-rwxr-xr-x | ci/run_tests.sh | 42 | ||||
-rw-r--r-- | runtime/lua/vim/_editor.lua | 5 | ||||
-rw-r--r-- | src/nvim/charset.c | 10 | ||||
-rw-r--r-- | src/nvim/regexp.c | 10 | ||||
-rw-r--r-- | src/nvim/testdir/test_regexp_latin.vim | 16 | ||||
-rw-r--r-- | test/functional/editor/completion_spec.lua | 19 | ||||
-rw-r--r-- | test/functional/lua/command_line_completion_spec.lua | 8 | ||||
-rw-r--r-- | third-party/CMakeLists.txt | 4 |
12 files changed, 110 insertions, 124 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41a22af538..ea3185d2a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,11 +80,11 @@ jobs: run: ./ci/before_script.sh - name: Build nvim - run: ./ci/run_tests.sh build + run: ./ci/run_tests.sh build_nvim - if: "!cancelled()" - name: clint - run: ./ci/run_lint.sh clint + name: clint-full + run: ./ci/run_lint.sh clint-full - if: "!cancelled()" name: lualint @@ -99,8 +99,8 @@ jobs: run: ./ci/run_lint.sh shlint - if: "!cancelled()" - name: single-includes - run: ./ci/run_lint.sh single-includes + name: check-single-includes + run: ./ci/run_lint.sh check-single-includes - name: Cache dependencies run: ./ci/before_cache.sh @@ -201,7 +201,7 @@ jobs: run: ./ci/before_script.sh - name: Build - run: ./ci/run_tests.sh build + run: ./ci/run_tests.sh build_nvim - if: matrix.flavor != 'tsan' && matrix.flavor != 'functionaltest-lua' && !cancelled() name: Unittests diff --git a/ci/common/suite.sh b/ci/common/suite.sh index 5110e22ec2..c0c470dce1 100644 --- a/ci/common/suite.sh +++ b/ci/common/suite.sh @@ -1,9 +1,3 @@ -# HACK: get newline for use in strings given that "\n" and $'' do not work. -NL="$(printf '\nE')" -NL="${NL%E}" - -FAIL_SUMMARY="" - # Test success marker. If END_MARKER file exists, we know that all tests # finished. If FAIL_SUMMARY_FILE exists we know that some tests failed, this # file will contain information about failed tests. Build is considered @@ -11,35 +5,15 @@ FAIL_SUMMARY="" END_MARKER="$BUILD_DIR/.tests_finished" FAIL_SUMMARY_FILE="$BUILD_DIR/.test_errors" -enter_suite() { - FAILED=0 - rm -f "${END_MARKER}" - local suite_name="$1" - export NVIM_TEST_CURRENT_SUITE="${NVIM_TEST_CURRENT_SUITE}/$suite_name" -} - -exit_suite() { - if test $FAILED -ne 0 ; then - echo "Suite ${NVIM_TEST_CURRENT_SUITE} failed, summary:" - echo "${FAIL_SUMMARY}" - fi - export NVIM_TEST_CURRENT_SUITE="${NVIM_TEST_CURRENT_SUITE%/*}" - FAILED=0 -} - fail() { local test_name="$1" - local fail_char="$2" - local message="$3" + local message="$2" - : ${fail_char:=F} : ${message:=Test $test_name failed} - local full_msg="$fail_char $NVIM_TEST_CURRENT_SUITE|$test_name :: $message" - FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" + local full_msg="$test_name :: $message" echo "${full_msg}" >> "${FAIL_SUMMARY_FILE}" echo "Failed: $full_msg" - FAILED=1 } ended_successfully() { @@ -64,13 +38,3 @@ end_tests() { touch "${END_MARKER}" ended_successfully } - -run_suite() { - local command="$1" - local suite_name="$2" - - enter_suite "$suite_name" - eval "$command" || fail "$suite_name" - exit_suite -} - diff --git a/ci/common/test.sh b/ci/common/test.sh index f211a2e7aa..7db39a0e5f 100644 --- a/ci/common/test.sh +++ b/ci/common/test.sh @@ -51,7 +51,7 @@ check_core_dumps() { fi done if test "$app" != quiet ; then - fail 'cores' E 'Core dumps found' + fail 'cores' 'Core dumps found' fi } @@ -72,7 +72,7 @@ check_logs() { rm "${log}" done if test -n "${err}" ; then - fail 'logs' E 'Runtime errors detected.' + fail 'logs' 'Runtime errors detected.' fi } @@ -86,19 +86,19 @@ check_sanitizer() { fi } -run_unittests() {( +unittests() {( ulimit -c unlimited || true if ! build_make unittest ; then - fail 'unittests' F 'Unit tests failed' + fail 'unittests' 'Unit tests failed' fi submit_coverage unittest check_core_dumps "$(command -v luajit)" )} -run_functionaltests() {( +functionaltests() {( ulimit -c unlimited || true if ! build_make ${FUNCTIONALTEST}; then - fail 'functionaltests' F 'Functional tests failed' + fail 'functionaltests' 'Functional tests failed' fi submit_coverage functionaltest check_sanitizer "${LOG_DIR}" @@ -106,11 +106,11 @@ run_functionaltests() {( check_core_dumps )} -run_oldtests() {( +oldtests() {( ulimit -c unlimited || true if ! make oldtest; then reset - fail 'oldtests' F 'Legacy tests failed' + fail 'oldtests' 'Legacy tests failed' fi submit_coverage oldtest check_sanitizer "${LOG_DIR}" @@ -129,26 +129,25 @@ check_runtime_files() {( # Prefer failing the build over using more robust construct because files # with IFS are not welcome. if ! test -e "$file" ; then - fail "$test_name" E \ - "It appears that $file is only a part of the file name" + fail "$test_name" "It appears that $file is only a part of the file name" fi if ! test "$tst" "$INSTALL_PREFIX/share/nvim/runtime/$file" ; then - fail "$test_name" F "$(printf "$message" "$file")" + fail "$test_name" "$(printf "$message" "$file")" fi done )} install_nvim() {( if ! build_make install ; then - fail 'install' E 'make install failed' - exit_suite + fail 'install' 'make install failed' + exit 1 fi "${INSTALL_PREFIX}/bin/nvim" --version if ! "${INSTALL_PREFIX}/bin/nvim" -u NONE -e -c ':help' -c ':qall' ; then echo "Running ':help' in the installed nvim failed." echo "Maybe the helptags have not been generated properly." - fail 'help' F 'Failed running :help' + fail 'help' 'Failed running :help' fi # Check that all runtime files were installed @@ -169,6 +168,6 @@ install_nvim() {( local genvimsynf=syntax/vim/generated.vim local gpat='syn keyword vimFuncName .*eval' if ! grep -q "$gpat" "${INSTALL_PREFIX}/share/nvim/runtime/$genvimsynf" ; then - fail 'funcnames' F "It appears that $genvimsynf does not contain $gpat." + fail 'funcnames' "It appears that $genvimsynf does not contain $gpat." fi )} diff --git a/ci/run_lint.sh b/ci/run_lint.sh index 2fea7a40c0..3a524b4ed6 100755 --- a/ci/run_lint.sh +++ b/ci/run_lint.sh @@ -8,34 +8,17 @@ CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${CI_DIR}/common/build.sh" source "${CI_DIR}/common/suite.sh" -if [[ "$GITHUB_ACTIONS" != "true" ]]; then - run_suite 'make clint-full' 'clint' - run_suite 'make lualint' 'lualint' - run_suite 'make pylint' 'pylint' - run_suite 'make shlint' 'shlint' - run_suite 'make check-single-includes' 'single-includes' +rm -f "$END_MARKER" - end_tests +# Run all tests if no input argument is given +if (($# == 0)); then + tests=('clint-full' 'lualint' 'pylint' 'shlint' 'check-single-includes') else - case "$1" in - clint) - run_suite 'make clint-full' 'clint' - ;; - lualint) - run_suite 'make lualint' 'lualint' - ;; - pylint) - run_suite 'make pylint' 'pylint' - ;; - shlint) - run_suite 'make shlint' 'shlint' - ;; - single-includes) - run_suite 'make check-single-includes' 'single-includes' - ;; - *) - :;; - esac - - end_tests + tests=("$@") fi + +for i in "${tests[@]}"; do + make "$i" || fail "$i" +done + +end_tests diff --git a/ci/run_tests.sh b/ci/run_tests.sh index ae85246ab6..23460b682e 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -8,42 +8,28 @@ source "${CI_DIR}/common/build.sh" source "${CI_DIR}/common/test.sh" source "${CI_DIR}/common/suite.sh" +rm -f "$END_MARKER" -if [[ "$GITHUB_ACTIONS" != "true" ]]; then - run_suite 'build_nvim' 'build' +# Run all tests (with some caveats) if no input argument is given +if (($# == 0)); then + tests=('build_nvim') if test "$CLANG_SANITIZER" != "TSAN"; then # Additional threads are only created when the builtin UI starts, which # doesn't happen in the unit/functional tests if test "${FUNCTIONALTEST}" != "functionaltest-lua"; then - run_suite run_unittests unittests + tests+=('unittests') fi - run_suite run_functionaltests functionaltests + tests+=('functionaltests') fi - run_suite run_oldtests oldtests - run_suite install_nvim install_nvim - end_tests + tests+=('oldtests' 'install_nvim') else - case "$1" in - build) - run_suite 'build_nvim' 'build' - ;; - unittests) - run_suite 'run_unittests' 'unittests' - ;; - functionaltests) - run_suite 'run_functionaltests' 'functionaltests' - ;; - oldtests) - run_suite 'run_oldtests' 'oldtests' - ;; - install_nvim) - run_suite 'install_nvim' 'install_nvim' - ;; - *) - :;; - esac - - end_tests + tests=("$@") fi + +for i in "${tests[@]}"; do + eval "$i" || fail "$i" +done + +end_tests diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 2251aca004..3136e36043 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -519,6 +519,8 @@ function vim._expand_pat(pat, env) local mt = getmetatable(final_env) if mt and type(mt.__index) == "table" then field = rawget(mt.__index, key) + elseif final_env == vim and vim._submodules[key] then + field = vim[key] end end final_env = field @@ -545,6 +547,9 @@ function vim._expand_pat(pat, env) if mt and type(mt.__index) == "table" then insert_keys(mt.__index) end + if final_env == vim then + insert_keys(vim._submodules) + end table.sort(keys) diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 97aac67627..3383dd2a76 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -928,10 +928,12 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en // continue until the NUL posptr = NULL; } else { - // Special check for an empty line, which can happen on exit, when - // ml_get_buf() always returns an empty string. - if (*ptr == NUL) { - pos->col = 0; + // In a few cases the position can be beyond the end of the line. + for (colnr_T i = 0; i < pos->col; i++) { + if (ptr[i] == NUL) { + pos->col = i; + break; + } } posptr = ptr + pos->col; posptr -= utf_head_off(line, posptr); diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 412cdac21b..009a26d4e0 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1136,8 +1136,8 @@ static bool reg_match_visual(void) return false; } + col = (colnr_T)(rex.input - rex.line); if (mode == 'v') { - col = (colnr_T)(rex.input - rex.line); if ((lnum == top.lnum && col < top.col) || (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e'))) { return false; @@ -1152,8 +1152,12 @@ static bool reg_match_visual(void) if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL) { end = MAXCOL; } - unsigned int cols_u = win_linetabsize(wp, rex.line, - (colnr_T)(rex.input - rex.line)); + + // getvvcol() flushes rex.line, need to get it again + rex.line = reg_getline(rex.lnum); + rex.input = rex.line + col; + + unsigned int cols_u = win_linetabsize(wp, rex.line, col); assert(cols_u <= MAXCOL); colnr_T cols = (colnr_T)cols_u; if (cols < start || cols > end - (*p_sel == 'e')) { diff --git a/src/nvim/testdir/test_regexp_latin.vim b/src/nvim/testdir/test_regexp_latin.vim index a92f7e1192..a0f5ebfb9f 100644 --- a/src/nvim/testdir/test_regexp_latin.vim +++ b/src/nvim/testdir/test_regexp_latin.vim @@ -795,4 +795,20 @@ func Test_using_mark_position() bwipe! endfunc +func Test_using_visual_position() + " this was using freed memory + new + exe "norm 0o\<Esc>\<C-V>k\<C-X>o0" + /\%V + bwipe! +endfunc + +func Test_using_invalid_visual_position() + " this was going beyond the end of the line + new + exe "norm 0o000\<Esc>0\<C-V>$s0" + /\%V + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index befad29922..1a0ee54505 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -1193,4 +1193,23 @@ describe('completion', function() eq('foobar', eval('g:word')) feed('<esc>') end) + + it('does not crash if text is changed by first call to complete function #17489', function() + source([[ + func Complete(findstart, base) abort + if a:findstart + let col = col('.') + call complete_add('#') + return col - 1 + else + return [] + endif + endfunc + + set completeopt=longest + set completefunc=Complete + ]]) + feed('ifoo#<C-X><C-U>') + assert_alive() + end) end) diff --git a/test/functional/lua/command_line_completion_spec.lua b/test/functional/lua/command_line_completion_spec.lua index 3ba7e1589f..3a5966755e 100644 --- a/test/functional/lua/command_line_completion_spec.lua +++ b/test/functional/lua/command_line_completion_spec.lua @@ -106,6 +106,14 @@ describe('nlua_expand_pat', function() ) end) + it('should work with lazy submodules of "vim" global', function() + eq({{ 'inspect' }, 4 }, + get_completions('vim.inspec')) + + eq({{ 'set' }, 11 }, + get_completions('vim.keymap.se')) + end) + it('should be able to interpolate globals', function() eq( {{ diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 30c4752b87..8a8720fca3 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -144,8 +144,8 @@ endif() include(ExternalProject) -set(LIBUV_URL https://github.com/libuv/libuv/archive/v1.44.0.tar.gz) -set(LIBUV_SHA256 f2482d547009d26d4d590ed6588043c540e707c833df52536744cb9a809e6617) +set(LIBUV_URL https://github.com/libuv/libuv/archive/v1.44.1.tar.gz) +set(LIBUV_SHA256 e91614e6dc2dd0bfdd140ceace49438882206b7a6fb00b8750914e67a9ed6d6b) set(MSGPACK_URL https://github.com/msgpack/msgpack-c/releases/download/cpp-3.0.0/msgpack-3.0.0.tar.gz) set(MSGPACK_SHA256 bfbb71b7c02f806393bc3cbc491b40523b89e64f83860c58e3e54af47de176e4) |