aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c31
-rw-r--r--src/nvim/eval.h7
-rw-r--r--src/nvim/ex_cmds2.c2
-rw-r--r--src/nvim/message.c19
-rw-r--r--src/nvim/msgpack_rpc/helpers.c2
-rw-r--r--src/nvim/os/shell.c4
-rw-r--r--src/nvim/rbuffer.c4
-rw-r--r--src/nvim/testdir/runtest.vim6
-rw-r--r--src/nvim/testdir/test_viml.vim8
-rw-r--r--src/nvim/ui.c4
-rw-r--r--src/nvim/version.c14
-rw-r--r--src/nvim/vim.h8
12 files changed, 86 insertions, 23 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index fc2f435508..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);
@@ -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/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 b0cfe2d6cd..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; \
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/testdir/runtest.vim b/src/nvim/testdir/runtest.vim
index 34b6b846ca..d1857565a4 100644
--- a/src/nvim/testdir/runtest.vim
+++ b/src/nvim/testdir/runtest.vim
@@ -59,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")
@@ -131,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_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/ui.c b/src/nvim/ui.c
index cc0d2ad1b4..ea0bccb1cd 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 82a6f5f9a9..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
@@ -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
@@ -734,7 +734,7 @@ static int included_patches[] = {
// 1713 NA
1712,
// 1711,
- // 1710,
+ // 1710 NA
// 1709 NA
// 1708,
// 1707,
@@ -743,9 +743,9 @@ static int included_patches[] = {
1704,
1703,
// 1702,
- // 1701,
+ 1701,
1700,
- // 1699,
+ 1699,
// 1698 NA
1697,
1696,
@@ -758,7 +758,7 @@ static int included_patches[] = {
// 1689 NA
// 1688 NA
// 1687 NA
- // 1686,
+ 1686,
// 1685,
// 1684 NA
// 1683 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