aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--CMakeLists.txt15
-rw-r--r--cmake/RunTests.cmake3
-rw-r--r--runtime/doc/change.txt4
-rw-r--r--src/nvim/api/private/helpers.c2
-rw-r--r--src/nvim/api/vim.c2
-rw-r--r--src/nvim/eval.c8
-rw-r--r--src/nvim/eval/decode.c8
-rw-r--r--src/nvim/fold.c71
-rw-r--r--src/nvim/move.PVS-Studio.cfg10
-rw-r--r--src/nvim/msgpack_rpc/helpers.c13
-rw-r--r--src/nvim/option.c24
-rw-r--r--src/nvim/option_defs.h6
-rw-r--r--src/nvim/os/win_defs.h2
-rw-r--r--src/nvim/testdir/test_fold.vim118
-rw-r--r--src/nvim/version.c2
-rw-r--r--test/functional/api/vim_spec.lua22
-rw-r--r--test/functional/core/job_spec.lua3
-rw-r--r--test/functional/helpers.lua2
-rw-r--r--test/functional/legacy/051_highlight_spec.lua2
-rw-r--r--test/functional/normal/fold_spec.lua112
-rw-r--r--test/helpers.lua41
-rw-r--r--third-party/CMakeLists.txt4
-rw-r--r--third-party/cmake/BuildMsgpack.cmake3
24 files changed, 381 insertions, 102 deletions
diff --git a/.gitignore b/.gitignore
index 68c0e9d17c..fb506305b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,9 +39,6 @@ tags
# generated by luacheck during `make testlint'
/test/.luacheckcache
-# luarocks, not added as a subtree because of the large number of blobs
-/third-party/luarocks
-
# local make targets
local.mk
@@ -49,6 +46,3 @@ local.mk
/runtime/doc/*.html
/runtime/doc/tags.ref
/runtime/doc/errors.log
-
-# clint errors, generated by `make lint`
-/errors.json
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1a058f2bff..e8956c9074 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -310,6 +310,21 @@ include_directories(SYSTEM ${LIBUV_INCLUDE_DIRS})
find_package(Msgpack 1.0.0 REQUIRED)
include_directories(SYSTEM ${MSGPACK_INCLUDE_DIRS})
+list(APPEND CMAKE_REQUIRED_INCLUDES "${MSGPACK_INCLUDE_DIRS}")
+check_c_source_compiles("
+#include <msgpack.h>
+
+int
+main(void)
+{
+ return MSGPACK_OBJECT_FLOAT32;
+}
+" MSGPACK_HAS_FLOAT32)
+
+if(MSGPACK_HAS_FLOAT32)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVIM_MSGPACK_HAS_FLOAT32")
+endif()
+
if(UNIX)
option(FEAT_TUI "Enable the Terminal UI" ON)
else()
diff --git a/cmake/RunTests.cmake b/cmake/RunTests.cmake
index 38e0f35213..bd7b630708 100644
--- a/cmake/RunTests.cmake
+++ b/cmake/RunTests.cmake
@@ -25,6 +25,8 @@ if(DEFINED ENV{TEST_FILTER})
set(TEST_TAG "--filter=$ENV{TEST_FILTER}")
endif()
+execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${WORKING_DIR}/Xtest-tmpdir)
+set(ENV{TMPDIR} ${WORKING_DIR}/Xtest-tmpdir)
set(ENV{SYSTEM_NAME} ${SYSTEM_NAME})
execute_process(
COMMAND ${BUSTED_PRG} ${TEST_TAG} ${TEST_FILTER} -v -o ${BUSTED_OUTPUT_TYPE}
@@ -37,6 +39,7 @@ execute_process(
file(REMOVE ${WORKING_DIR}/Xtest_rplugin_manifest)
file(REMOVE_RECURSE ${WORKING_DIR}/Xtest_xdg)
+file(REMOVE_RECURSE ${WORKING_DIR}/Xtest-tmpdir)
if(NOT res EQUAL 0)
message(STATUS "Output to stderr:\n${err}")
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
index c8576d83e8..e0974b103c 100644
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -601,8 +601,8 @@ all files in it are deleted. When Vim has the setuid bit set this may cause
problems, the temp file is owned by the setuid user but the filter command
probably runs as the original user.
Directory for temporary files is created in the first suitable directory of:
-For Unix: $TMPDIR, /tmp, current-dir, $HOME.
-For MS-Windows: $TMP, $TEMP, $USERPROFILE, current-dir.
+ Unix: $TMPDIR, /tmp, current-dir, $HOME.
+ Windows: $TMPDIR, $TMP, $TEMP, $USERPROFILE, current-dir.
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index b245132ba7..fe15b28041 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -289,7 +289,7 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
}
}
- int opt_flags = (type ? OPT_LOCAL : OPT_GLOBAL);
+ int opt_flags = (type == SREQ_GLOBAL) ? OPT_GLOBAL : OPT_LOCAL;
if (flags & SOPT_BOOL) {
if (value.type != kObjectTypeBoolean) {
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 975446057c..6926436d2f 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -440,7 +440,7 @@ Object nvim_get_vvar(String name, Error *err)
///
/// @param name Option name
/// @param[out] err Error details, if any
-/// @return Option value
+/// @return Option value (global)
Object nvim_get_option(String name, Error *err)
FUNC_API_SINCE(1)
{
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index c683fe4e10..15b712e7de 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -20712,13 +20712,7 @@ void func_unref(char_u *name)
abort();
#endif
}
- if (fp != NULL && --fp->uf_refcount <= 0) {
- // Only delete it when it's not being used. Otherwise it's done
- // when "uf_calls" becomes zero.
- if (fp->uf_calls == 0) {
- func_clear_free(fp, false);
- }
- }
+ func_ptr_unref(fp);
}
/// Unreference a Function: decrement the reference count and free it when it
diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c
index 3cb68e093b..fb31a65971 100644
--- a/src/nvim/eval/decode.c
+++ b/src/nvim/eval/decode.c
@@ -973,7 +973,13 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv)
}
break;
}
- case MSGPACK_OBJECT_FLOAT: {
+#ifdef NVIM_MSGPACK_HAS_FLOAT32
+ case MSGPACK_OBJECT_FLOAT32:
+ case MSGPACK_OBJECT_FLOAT64:
+#else
+ case MSGPACK_OBJECT_FLOAT:
+#endif
+ {
*rettv = (typval_T) {
.v_type = VAR_FLOAT,
.v_lock = VAR_UNLOCKED,
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 36a5b0efd7..d810aee0ce 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -2232,32 +2232,51 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
* before where we started looking, extend it. If it
* starts at another line, update nested folds to keep
* their position, compensating for the new fd_top. */
- if (fp->fd_top >= startlnum && fp->fd_top != firstlnum) {
- if (fp->fd_top > firstlnum)
- /* like lines are inserted */
+ if (fp->fd_top == firstlnum) {
+ // We have found a fold beginning exactly where we want one.
+ } else if (fp->fd_top >= startlnum) {
+ if (fp->fd_top > firstlnum) {
+ // We will move the start of this fold up, hence we move all
+ // nested folds (with relative line numbers) down.
foldMarkAdjustRecurse(&fp->fd_nested,
- (linenr_T)0, (linenr_T)MAXLNUM,
- (long)(fp->fd_top - firstlnum), 0L);
- else
- /* like lines are deleted */
+ (linenr_T)0, (linenr_T)MAXLNUM,
+ (long)(fp->fd_top - firstlnum), 0L);
+ } else {
+ // Will move fold down, move nested folds relatively up.
foldMarkAdjustRecurse(&fp->fd_nested,
- (linenr_T)0,
- (long)(firstlnum - fp->fd_top - 1),
- (linenr_T)MAXLNUM,
- (long)(fp->fd_top - firstlnum));
+ (linenr_T)0,
+ (long)(firstlnum - fp->fd_top - 1),
+ (linenr_T)MAXLNUM,
+ (long)(fp->fd_top - firstlnum));
+ }
fp->fd_len += fp->fd_top - firstlnum;
fp->fd_top = firstlnum;
- fold_changed = TRUE;
- } else if (flp->start != 0 && lvl == level
- && fp->fd_top != firstlnum) {
- /* Existing fold that includes startlnum must stop
- * if we find the start of a new fold at the same
- * level. Split it. Delete contained folds at
- * this point to split them too. */
- foldRemove(&fp->fd_nested, flp->lnum - fp->fd_top,
- flp->lnum - fp->fd_top);
+ fold_changed = true;
+ } else if ((flp->start != 0 && lvl == level)
+ || (firstlnum != startlnum)) {
+ // Before there was a fold spanning from above startlnum to below
+ // firstlnum. This fold is valid above startlnum (because we are
+ // not updating that range), but there is now a break in it.
+ // If the break is because we are now forced to start a new fold
+ // at the level "level" at line fline->lnum, then we need to
+ // split the fold at fline->lnum.
+ // If the break is because the range [startlnum, firstlnum) is
+ // now at a lower indent than "level", we need to split the fold
+ // in this range.
+ // Any splits have to be done recursively.
+ linenr_T breakstart;
+ linenr_T breakend;
+ if (firstlnum != startlnum) {
+ breakstart = startlnum;
+ breakend = firstlnum;
+ } else {
+ breakstart = flp->lnum;
+ breakend = flp->lnum;
+ }
+ foldRemove(&fp->fd_nested, breakstart - fp->fd_top,
+ breakend - fp->fd_top);
i = (int)(fp - (fold_T *)gap->ga_data);
- foldSplit(gap, i, flp->lnum, flp->lnum - 1);
+ foldSplit(gap, i, breakstart, breakend - 1);
fp = (fold_T *)gap->ga_data + i + 1;
/* If using the "marker" or "syntax" method, we
* need to continue until the end of the fold is
@@ -2267,6 +2286,16 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|| getlevel == foldlevelSyntax)
finish = TRUE;
}
+ if (fp->fd_top == startlnum && concat) {
+ i = (int)(fp - (fold_T *)gap->ga_data);
+ if (i != 0) {
+ fp2 = fp - 1;
+ if (fp2->fd_top + fp2->fd_len == fp->fd_top) {
+ foldMerge(fp2, gap, fp);
+ fp = fp2;
+ }
+ }
+ }
break;
}
if (fp->fd_top >= startlnum) {
diff --git a/src/nvim/move.PVS-Studio.cfg b/src/nvim/move.PVS-Studio.cfg
deleted file mode 100644
index cb6da32f12..0000000000
--- a/src/nvim/move.PVS-Studio.cfg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-source-file=/home/zyx/a.a/Proj/c/neovim/src/nvim/move.c
-i-file=/home/zyx/a.a/Proj/c/neovim/src/nvim/move.i
-language=C
-skip-cl-exe=yes
-preprocessor=gcc
-platform=linux64
-lic-file=/home/zyx/a.a/Proj/c/neovim/build/../PVS-Studio.lic
-output-file=/home/zyx/a.a/Proj/c/neovim/build/../PVS-Studio.log.x
-analysis-mode=4
diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c
index 808bb863fd..4d8a9984e1 100644
--- a/src/nvim/msgpack_rpc/helpers.c
+++ b/src/nvim/msgpack_rpc/helpers.c
@@ -114,7 +114,13 @@ bool msgpack_rpc_to_object(const msgpack_object *const obj, Object *const arg)
}
break;
}
- case MSGPACK_OBJECT_FLOAT: {
+#ifdef NVIM_MSGPACK_HAS_FLOAT32
+ case MSGPACK_OBJECT_FLOAT32:
+ case MSGPACK_OBJECT_FLOAT64:
+#else
+ case MSGPACK_OBJECT_FLOAT:
+#endif
+ {
STATIC_ASSERT(sizeof(Float) == sizeof(cur.mobj->via.f64),
"Msgpack floating-point size does not match API integer");
*cur.aobj = FLOATING_OBJ(cur.mobj->via.f64);
@@ -181,7 +187,12 @@ bool msgpack_rpc_to_object(const msgpack_object *const obj, Object *const arg)
case MSGPACK_OBJECT_BOOLEAN:
case MSGPACK_OBJECT_POSITIVE_INTEGER:
case MSGPACK_OBJECT_NEGATIVE_INTEGER:
+#ifdef NVIM_MSGPACK_HAS_FLOAT32
+ case MSGPACK_OBJECT_FLOAT32:
+ case MSGPACK_OBJECT_FLOAT64:
+#else
case MSGPACK_OBJECT_FLOAT:
+#endif
case MSGPACK_OBJECT_EXT:
case MSGPACK_OBJECT_MAP:
case MSGPACK_OBJECT_ARRAY: {
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 69c12e2cc7..0b4d9aae5d 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -4621,14 +4621,13 @@ int get_option_value_strict(char *name,
}
char_u *varp = NULL;
- vimoption_T *p;
int rv = 0;
int opt_idx = findoption(name);
if (opt_idx < 0) {
return 0;
}
- p = &(options[opt_idx]);
+ vimoption_T *p = &options[opt_idx];
// Hidden option
if (p->var == NULL) {
@@ -4644,26 +4643,25 @@ int get_option_value_strict(char *name,
}
if (p->indir == PV_NONE) {
- if (opt_type == SREQ_GLOBAL)
+ if (opt_type == SREQ_GLOBAL) {
rv |= SOPT_GLOBAL;
- else
- return 0; // Did not request global-only option
+ } else {
+ return 0; // Did not request global-only option
+ }
} else {
if (p->indir & PV_BOTH) {
rv |= SOPT_GLOBAL;
- } else if (opt_type == SREQ_GLOBAL) {
- return 0; // Requested global option
}
if (p->indir & PV_WIN) {
if (opt_type == SREQ_BUF) {
- return 0; // Did not request window-local option
+ return 0; // Requested buffer-local, not window-local option
} else {
rv |= SOPT_WIN;
}
} else if (p->indir & PV_BUF) {
if (opt_type == SREQ_WIN) {
- return 0; // Did not request buffer-local option
+ return 0; // Requested window-local, not buffer-local option
} else {
rv |= SOPT_BUF;
}
@@ -4675,7 +4673,11 @@ int get_option_value_strict(char *name,
}
if (opt_type == SREQ_GLOBAL) {
- varp = p->var;
+ if (p->var == VAR_WIN) {
+ return 0;
+ } else {
+ varp = p->var;
+ }
} else {
if (opt_type == SREQ_BUF) {
// Special case: 'modified' is b_changed, but we also want to
@@ -4722,7 +4724,7 @@ int get_option_value_strict(char *name,
/// @param[in] name Option name.
/// @param[in] number New value for the number or boolean option.
/// @param[in] string New value for string option.
-/// @param[in] opt_flags Flags: OPT_LOCAL or 0 (both).
+/// @param[in] opt_flags Flags: OPT_LOCAL, OPT_GLOBAL, or 0 (both).
///
/// @return NULL on success, error message on error.
char *set_option_value(const char *const name, const long number,
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index 94c6361236..2475a0b6a1 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -16,9 +16,9 @@
#define SOPT_UNSET 0x40 // Option does not have local value set
// Option types for various functions in option.c
-#define SREQ_GLOBAL 0 // Request global option
-#define SREQ_WIN 1 // Request window-local option
-#define SREQ_BUF 2 // Request buffer-local option
+#define SREQ_GLOBAL 0 // Request global option value
+#define SREQ_WIN 1 // Request window-local option value
+#define SREQ_BUF 2 // Request buffer-local option value
/*
* Default values for 'errorformat'.
diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h
index 827fb2f247..7c980c3768 100644
--- a/src/nvim/os/win_defs.h
+++ b/src/nvim/os/win_defs.h
@@ -19,7 +19,7 @@
#define NAME_MAX _MAX_PATH
-#define TEMP_DIR_NAMES { "$TMP", "$TEMP", "$USERPROFILE", "" }
+#define TEMP_DIR_NAMES { "$TMPDIR", "$TMP", "$TEMP", "$USERPROFILE", "" }
#define TEMP_FILE_PATH_MAXLEN _MAX_PATH
#define FNAME_ILLEGAL "\"*?><|"
diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim
index 976c6b5cd1..46c54e8614 100644
--- a/src/nvim/testdir/test_fold.vim
+++ b/src/nvim/testdir/test_fold.vim
@@ -100,22 +100,6 @@ func! Test_indent_fold2()
bw!
endfunc
-func Test_folds_marker_in_comment()
- new
- call setline(1, ['" foo', 'bar', 'baz'])
- setl fen fdm=marker
- setl com=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\" cms=\"%s
- norm! zf2j
- setl nofen
- :1y
- call assert_equal(['" foo{{{'], getreg(0,1,1))
- :+2y
- call assert_equal(['baz"}}}'], getreg(0,1,1))
-
- set foldmethod&
- bwipe!
-endfunc
-
func Test_manual_fold_with_filter()
if !executable('cat')
return
@@ -138,6 +122,108 @@ func Test_manual_fold_with_filter()
endfor
endfunc
+func! Test_indent_fold_with_read()
+ new
+ set foldmethod=indent
+ call setline(1, repeat(["\<Tab>a"], 4))
+ for n in range(1, 4)
+ call assert_equal(1, foldlevel(n))
+ endfor
+
+ call writefile(["a", "", "\<Tab>a"], 'Xfile')
+ foldopen
+ 2read Xfile
+ %foldclose
+ call assert_equal(1, foldlevel(1))
+ call assert_equal(2, foldclosedend(1))
+ call assert_equal(0, foldlevel(3))
+ call assert_equal(0, foldlevel(4))
+ call assert_equal(1, foldlevel(5))
+ call assert_equal(7, foldclosedend(5))
+
+ bwipe!
+ set foldmethod&
+ call delete('Xfile')
+endfunc
+
+func Test_combining_folds_indent()
+ new
+ let one = "\<Tab>a"
+ let zero = 'a'
+ call setline(1, [one, one, zero, zero, zero, one, one, one])
+ set foldmethod=indent
+ 3,5d
+ %foldclose
+ call assert_equal(5, foldclosedend(1))
+
+ set foldmethod&
+ bwipe!
+endfunc
+
+func Test_combining_folds_marker()
+ new
+ call setline(1, ['{{{', '}}}', '', '', '', '{{{', '', '}}}'])
+ set foldmethod=marker
+ 3,5d
+ %foldclose
+ call assert_equal(2, foldclosedend(1))
+
+ set foldmethod&
+ bwipe!
+endfunc
+
+func Test_folds_marker_in_comment()
+ new
+ call setline(1, ['" foo', 'bar', 'baz'])
+ setl fen fdm=marker
+ setl com=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\" cms=\"%s
+ norm! zf2j
+ setl nofen
+ :1y
+ call assert_equal(['" foo{{{'], getreg(0,1,1))
+ :+2y
+ call assert_equal(['baz"}}}'], getreg(0,1,1))
+
+ set foldmethod&
+ bwipe!
+endfunc
+
+func s:TestFoldExpr(lnum)
+ let thisline = getline(a:lnum)
+ if thisline == 'a'
+ return 1
+ elseif thisline == 'b'
+ return 0
+ elseif thisline == 'c'
+ return '<1'
+ elseif thisline == 'd'
+ return '>1'
+ endif
+ return 0
+endfunction
+
+func Test_update_folds_expr_read()
+ new
+ call setline(1, ['a', 'a', 'a', 'a', 'a', 'a'])
+ set foldmethod=expr
+ set foldexpr=s:TestFoldExpr(v:lnum)
+ 2
+ foldopen
+ call writefile(['b', 'b', 'a', 'a', 'd', 'a', 'a', 'c'], 'Xfile')
+ read Xfile
+ %foldclose
+ call assert_equal(2, foldclosedend(1))
+ call assert_equal(0, foldlevel(3))
+ call assert_equal(0, foldlevel(4))
+ call assert_equal(6, foldclosedend(5))
+ call assert_equal(10, foldclosedend(7))
+ call assert_equal(14, foldclosedend(11))
+
+ call delete('Xfile')
+ bwipe!
+ set foldmethod& foldexpr&
+endfunc
+
func! Test_move_folds_around_manual()
new
let input = PrepIndent("a") + PrepIndent("b") + PrepIndent("c")
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 9275a2e5bd..fdf5436a98 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -337,7 +337,7 @@ static const int included_patches[] = {
2107,
2106,
// 2105 NA
- // 2104,
+ 2104,
2103,
// 2102 NA
2101,
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 3348368a36..8f9f155110 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -153,6 +153,28 @@ describe('api', function()
nvim('set_option', 'equalalways', false)
ok(not nvim('get_option', 'equalalways'))
end)
+
+ it('works to get global value of local options', function()
+ eq(false, nvim('get_option', 'lisp'))
+ eq(8, nvim('get_option', 'shiftwidth'))
+ end)
+
+ it('works to set global value of local options', function()
+ nvim('set_option', 'lisp', true)
+ eq(true, nvim('get_option', 'lisp'))
+ eq(false, helpers.curbuf('get_option', 'lisp'))
+ eq(nil, nvim('command_output', 'setglobal lisp?'):match('nolisp'))
+ eq('nolisp', nvim('command_output', 'setlocal lisp?'):match('nolisp'))
+ nvim('set_option', 'shiftwidth', 20)
+ eq('20', nvim('command_output', 'setglobal shiftwidth?'):match('%d+'))
+ eq('8', nvim('command_output', 'setlocal shiftwidth?'):match('%d+'))
+ end)
+
+ it('most window-local options have no global value', function()
+ local status, err = pcall(nvim, 'get_option', 'foldcolumn')
+ eq(false, status)
+ ok(err:match('Invalid option name') ~= nil)
+ end)
end)
describe('nvim_{get,set}_current_buf, nvim_list_bufs', function()
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index e442c2a317..9ee91f2fe9 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -8,6 +8,7 @@ local clear, eq, eval, exc_exec, execute, feed, insert, neq, next_msg, nvim,
local command = helpers.command
local wait = helpers.wait
local iswin = helpers.iswin
+local get_pathsep = helpers.get_pathsep
local Screen = require('test.functional.ui.screen')
describe('jobs', function()
@@ -65,7 +66,7 @@ describe('jobs', function()
end)
it('changes to given `cwd` directory', function()
- local dir = eval('resolve(tempname())')
+ local dir = eval("resolve(tempname())"):gsub("/", get_pathsep())
mkdir(dir)
nvim('command', "let g:job_opts.cwd = '" .. dir .. "'")
if iswin() then
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 7ce95d0b7c..ab36508262 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -23,7 +23,7 @@ local nvim_prog = os.getenv('NVIM_PROG') or os.getenv('NVIM_PRG') or 'build/bin/
-- Default settings for the test session.
local nvim_set = 'set shortmess+=I background=light noswapfile noautoindent'
..' laststatus=1 undodir=. directory=. viewdir=. backupdir=.'
- ..' belloff= noshowcmd noruler'
+ ..' belloff= noshowcmd noruler nomore'
local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
'--cmd', nvim_set, '--embed'}
diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua
index ef392d8c67..d4d9b7d997 100644
--- a/test/functional/legacy/051_highlight_spec.lua
+++ b/test/functional/legacy/051_highlight_spec.lua
@@ -16,7 +16,7 @@ describe(':highlight', function()
local screen = Screen.new(35, 10)
screen:attach()
-- Basic test if ":highlight" doesn't crash
- execute('highlight')
+ execute('set more', 'highlight')
-- FIXME(tarruda): We need to be sure the prompt is displayed before
-- continuing, or risk a race condition where some of the following input
-- is discarded resulting in test failure
diff --git a/test/functional/normal/fold_spec.lua b/test/functional/normal/fold_spec.lua
index 5584db20ba..fc055c4e7a 100644
--- a/test/functional/normal/fold_spec.lua
+++ b/test/functional/normal/fold_spec.lua
@@ -6,12 +6,15 @@ local feed = helpers.feed
local expect = helpers.expect
local execute = helpers.execute
local funcs = helpers.funcs
-local foldlevel, foldclosedend = funcs.foldlevel, funcs.foldclosedend
+local foldlevel = funcs.foldlevel
+local foldclosedend = funcs.foldclosedend
local eq = helpers.eq
describe('Folds', function()
+ local tempfname = 'Xtest-fold.txt'
clear()
before_each(function() execute('enew!') end)
+ after_each(function() os.remove(tempfname) end)
it('manual folding adjusts with filter', function()
insert([[
1
@@ -230,4 +233,111 @@ a]], '2,3m0')
eq({1, 2, 0, 0, 0}, get_folds())
end)
end)
+ it('updates correctly on :read', function()
+ -- luacheck: ignore 621
+ helpers.write_file(tempfname, [[
+ a
+
+
+ a]])
+ insert([[
+ a
+ a
+ a
+ a
+ ]])
+ execute('set foldmethod=indent', '2', '%foldopen')
+ execute('read ' .. tempfname)
+ -- Just to check we have the correct file text.
+ expect([[
+ a
+ a
+ a
+
+
+ a
+ a
+ a
+ ]])
+ for i = 1,2 do
+ eq(1, funcs.foldlevel(i))
+ end
+ for i = 3,5 do
+ eq(0, funcs.foldlevel(i))
+ end
+ for i = 6,8 do
+ eq(1, funcs.foldlevel(i))
+ end
+ end)
+ it('combines folds when removing separating space', function()
+ -- luacheck: ignore 621
+ insert([[
+ a
+ a
+ a
+ a
+ a
+ a
+ a
+ a
+ ]])
+ execute('set foldmethod=indent', '3,5d')
+ eq(5, funcs.foldclosedend(1))
+ end)
+ it("doesn't combine folds that have a specified end", function()
+ insert([[
+ {{{
+ }}}
+
+
+
+ {{{
+
+ }}}
+ ]])
+ execute('set foldmethod=marker', '3,5d', '%foldclose')
+ eq(2, funcs.foldclosedend(1))
+ end)
+ it('splits folds according to >N and <N with foldexpr', function()
+ helpers.source([[
+ function TestFoldExpr(lnum)
+ let thisline = getline(a:lnum)
+ if thisline == 'a'
+ return 1
+ elseif thisline == 'b'
+ return 0
+ elseif thisline == 'c'
+ return '<1'
+ elseif thisline == 'd'
+ return '>1'
+ endif
+ return 0
+ endfunction
+ ]])
+ helpers.write_file(tempfname, [[
+ b
+ b
+ a
+ a
+ d
+ a
+ a
+ c]])
+ insert([[
+ a
+ a
+ a
+ a
+ a
+ a
+ ]])
+ execute('set foldmethod=expr', 'set foldexpr=TestFoldExpr(v:lnum)', '2', 'foldopen')
+ execute('read ' .. tempfname, '%foldclose')
+ eq(2, funcs.foldclosedend(1))
+ eq(0, funcs.foldlevel(3))
+ eq(0, funcs.foldlevel(4))
+ eq(6, funcs.foldclosedend(5))
+ eq(10, funcs.foldclosedend(7))
+ eq(14, funcs.foldclosedend(11))
+ end)
end)
diff --git a/test/helpers.lua b/test/helpers.lua
index 1a86effa1c..82451bc61d 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -106,20 +106,33 @@ local uname = (function()
end)
end)()
-local function tmpname()
- local fname = os.tmpname()
- if uname() == 'Windows' and fname:sub(1, 2) == '\\s' then
- -- In Windows tmpname() returns a filename starting with
- -- special sequence \s, prepend $TEMP path
- local tmpdir = os.getenv('TEMP')
- return tmpdir..fname
- elseif fname:match('^/tmp') and uname() == 'Darwin' then
- -- In OS X /tmp links to /private/tmp
- return '/private'..fname
- else
- return fname
- end
-end
+local tmpname = (function()
+ local seq = 0
+ local tmpdir = os.getenv('TMPDIR') and os.getenv('TMPDIR') or os.getenv('TEMP')
+ -- Is $TMPDIR defined local to the project workspace?
+ local in_workspace = not not (tmpdir and string.find(tmpdir, 'Xtest'))
+ return (function()
+ if in_workspace then
+ -- Cannot control os.tmpname() dir, so hack our own tmpname() impl.
+ seq = seq + 1
+ local fname = tmpdir..'/nvim-test-lua-'..seq
+ io.open(fname, 'w'):close()
+ return fname
+ else
+ local fname = os.tmpname()
+ if uname() == 'Windows' and fname:sub(1, 2) == '\\s' then
+ -- In Windows tmpname() returns a filename starting with
+ -- special sequence \s, prepend $TEMP path
+ return tmpdir..fname
+ elseif fname:match('^/tmp') and uname() == 'Darwin' then
+ -- In OS X /tmp links to /private/tmp
+ return '/private'..fname
+ else
+ return fname
+ end
+ end
+ end)
+end)()
local function map(func, tab)
local rettab = {}
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
index a5fd766aa8..ea1039f459 100644
--- a/third-party/CMakeLists.txt
+++ b/third-party/CMakeLists.txt
@@ -90,8 +90,8 @@ include(ExternalProject)
set(LIBUV_URL https://github.com/libuv/libuv/archive/v1.9.1.tar.gz)
set(LIBUV_SHA256 a6ca9f0648973d1463f46b495ce546ddcbe7cce2f04b32e802a15539e46c57ad)
-set(MSGPACK_URL https://github.com/msgpack/msgpack-c/archive/cpp-1.0.0.tar.gz)
-set(MSGPACK_SHA256 afda64ca445203bb7092372b822bae8b2539fdcebbfc3f753f393628c2bcfe7d)
+set(MSGPACK_URL https://github.com/msgpack/msgpack-c/archive/cpp-2.1.1.tar.gz)
+set(MSGPACK_SHA256 d6bef12d959816a39c7a6972f3f16c0724e4c7ff0927eb59a35247dc8267b609)
set(LUAJIT_URL https://github.com/neovim/deps/raw/master/opt/LuaJIT-2.0.4.tar.gz)
set(LUAJIT_SHA256 620fa4eb12375021bef6e4f237cbd2dd5d49e56beb414bee052c746beef1807d)
diff --git a/third-party/cmake/BuildMsgpack.cmake b/third-party/cmake/BuildMsgpack.cmake
index 6b38508b0b..779cb1ebfe 100644
--- a/third-party/cmake/BuildMsgpack.cmake
+++ b/third-party/cmake/BuildMsgpack.cmake
@@ -35,6 +35,7 @@ endfunction()
set(MSGPACK_CONFIGURE_COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/msgpack
-DMSGPACK_ENABLE_CXX=OFF
-DMSGPACK_BUILD_TESTS=OFF
+ -DMSGPACK_BUILD_EXAMPLES=OFF
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
@@ -49,6 +50,7 @@ if(MINGW AND CMAKE_CROSSCOMPILING)
set(MSGPACK_CONFIGURE_COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/msgpack
-DMSGPACK_ENABLE_CXX=OFF
-DMSGPACK_BUILD_TESTS=OFF
+ -DMSGPACK_BUILD_EXAMPLES=OFF
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
# Pass toolchain
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}
@@ -60,6 +62,7 @@ elseif(MSVC)
set(MSGPACK_CONFIGURE_COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/msgpack
-DMSGPACK_ENABLE_CXX=OFF
-DMSGPACK_BUILD_TESTS=OFF
+ -DMSGPACK_BUILD_EXAMPLES=OFF
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1}"