aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ci/build.ps14
-rw-r--r--contrib/local.mk.example5
-rw-r--r--runtime/doc/autocmd.txt11
-rw-r--r--runtime/doc/eval.txt28
-rw-r--r--runtime/doc/starting.txt14
-rw-r--r--src/nvim/auevents.lua2
-rw-r--r--src/nvim/channel.c6
-rw-r--r--src/nvim/eval.c50
-rw-r--r--src/nvim/eval.h1
-rw-r--r--src/nvim/eval.lua1
-rw-r--r--src/nvim/event/loop.c1
-rw-r--r--src/nvim/event/loop.h1
-rw-r--r--src/nvim/event/process.c54
-rw-r--r--src/nvim/event/process.h3
-rw-r--r--src/nvim/ex_docmd.c3
-rw-r--r--src/nvim/fileio.c10
-rw-r--r--src/nvim/main.c9
-rw-r--r--src/nvim/os/stdpaths.c2
-rw-r--r--src/nvim/terminal.c9
-rw-r--r--src/nvim/testdir/Makefile2
-rw-r--r--src/nvim/testdir/runtest.vim2
-rw-r--r--src/nvim/testdir/setup.vim8
-rw-r--r--src/nvim/testdir/test_cmdline.vim6
-rw-r--r--src/nvim/testdir/test_find_complete.vim3
-rw-r--r--src/nvim/testdir/test_help_tagjump.vim2
-rw-r--r--src/nvim/testdir/test_makeencoding.vim9
-rw-r--r--src/nvim/testdir/test_options.vim3
-rw-r--r--src/nvim/testdir/test_quickfix.vim16
-rw-r--r--src/nvim/testdir/test_recover.vim5
-rw-r--r--src/nvim/testdir/test_stat.vim2
-rw-r--r--src/nvim/testdir/test_system.vim10
-rw-r--r--test/functional/autocmd/termclose_spec.lua6
-rw-r--r--test/functional/core/job_spec.lua168
-rw-r--r--test/functional/eval/system_spec.lua8
-rw-r--r--test/functional/helpers.lua2
-rw-r--r--test/functional/options/defaults_spec.lua276
-rw-r--r--test/functional/terminal/mouse_spec.lua16
-rw-r--r--test/functional/terminal/tui_spec.lua10
-rw-r--r--test/functional/ui/screen_basic_spec.lua16
39 files changed, 600 insertions, 184 deletions
diff --git a/ci/build.ps1 b/ci/build.ps1
index 71cc7c5b50..8eb237ccd1 100644
--- a/ci/build.ps1
+++ b/ci/build.ps1
@@ -100,7 +100,7 @@ bin\nvim --version ; exitIfFailed
$failed = $false
# Temporarily turn off tracing to reduce log file output
Set-PSDebug -Off
-cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGeneratorArgs |
+cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGeneratorArgs 2>&1 |
foreach { $failed = $failed -or
$_ -match 'Running functional tests failed with error'; $_ }
Set-PSDebug -Trace 1
@@ -114,7 +114,7 @@ if ($uploadToCodecov) {
}
# Old tests
-$env:PATH += ';C:\msys64\usr\bin'
+$env:PATH = "C:\msys64\usr\bin;$env:PATH"
& "C:\msys64\mingw$bits\bin\mingw32-make.exe" -C $(Convert-Path ..\src\nvim\testdir) VERBOSE=1
if ($uploadToCodecov) {
diff --git a/contrib/local.mk.example b/contrib/local.mk.example
index 23fe11622b..c347eb9e0d 100644
--- a/contrib/local.mk.example
+++ b/contrib/local.mk.example
@@ -36,7 +36,6 @@
# them.
#
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_BUSTED=OFF
-# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_DEPS=OFF
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_JEMALLOC=OFF
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_LIBTERMKEY=OFF
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_LIBUV=OFF
@@ -45,6 +44,10 @@
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_LUAROCKS=OFF
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_MSGPACK=OFF
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_UNIBILIUM=OFF
+#
+# Or disable all bundled dependencies at once.
+#
+# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED=OFF
# By default, bundled libraries are statically linked to nvim.
# This has no effect for non-bundled deps, which are always dynamically linked.
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 9a04bf2824..06a016eddb 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -272,10 +272,11 @@ Name triggered by ~
|GUIEnter| after starting the GUI successfully
|GUIFailed| after starting the GUI failed
|TermResponse| after the terminal response to |t_RV| is received
-
|QuitPre| when using `:quit`, before deciding whether to quit
-|VimLeavePre| before exiting Vim, before writing the shada file
-|VimLeave| before exiting Vim, after writing the shada file
+|VimLeavePre| before exiting Nvim, before writing the shada file
+|VimLeave| before exiting Nvim, after writing the shada file
+|VimResume| after Nvim is resumed
+|VimSuspend| before Nvim is suspended
Various
|DirChanged| after the |current-directory| was changed
@@ -1009,6 +1010,10 @@ VimLeavePre Before exiting Vim, just before writing the
VimResized After the Vim window was resized, thus 'lines'
and/or 'columns' changed. Not when starting
up though.
+ *VimResume*
+VimResume After Nvim resumes from |suspend| state.
+ *VimSuspend*
+VimSuspend Before Nvim enters |suspend| state.
*WinEnter*
WinEnter After entering another window. Not done for
the first window, when Vim has just started.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 11c4b62403..fffdcef8d9 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2286,6 +2286,7 @@ split({expr} [, {pat} [, {keepempty}]])
List make |List| from {pat} separated {expr}
sqrt({expr}) Float square root of {expr}
stdioopen({dict}) Number open stdio in a headless instance.
+stdpath({what}) String/List returns the standard path(s) for {what}
str2float({expr}) Float convert String to Float
str2nr({expr} [, {base}]) Number convert String to Number
strchars({expr} [, {skipcc}]) Number character length of the String {expr}
@@ -4208,8 +4209,7 @@ getftype({fname}) *getftype()*
getftype("/home")
< Note that a type such as "link" will only be returned on
systems that support it. On some systems only "dir" and
- "file" are returned. On MS-Windows a symbolic link to a
- directory returns "dir" instead of "link".
+ "file" are returned.
*getline()*
getline({lnum} [, {end}])
@@ -5033,10 +5033,9 @@ jobstart({cmd}[, {opts}]) *jobstart()*
width : (pty only) Width of the terminal screen
height : (pty only) Height of the terminal screen
TERM : (pty only) $TERM environment variable
- detach : (non-pty only) Detach the job process from the
- nvim process. The process will not get killed
- when nvim exits. If the process dies before
- nvim exits, "on_exit" will still be invoked.
+ detach : (non-pty only) Detach the job process: it will
+ not be killed when Nvim exits. If the process
+ exits before Nvim, "on_exit" will be invoked.
{opts} is passed as |self| dictionary to the callback; the
caller may set other keys to pass application-specific data.
@@ -7263,6 +7262,23 @@ stdioopen({opts}) *stdioopen()*
- 0 on invalid arguments
+stdpath({what}) *stdpath()* *E6100*
+ Returns the standard path(s) for {what}.
+
+ These directories are the default locations for various files
+ used by Neovim.
+
+ {what} Type Description ~
+ cache String Cache directory. Useful for plugins
+ that need temporary files to work.
+ config String User configuration directory. The
+ |init.vim| is stored here.
+ config_dirs List Additional configuration directories.
+ data String User data directory. The |shada-file|
+ is stored here.
+ data_dirs List Additional data directories.
+
+
str2float({expr}) *str2float()*
Convert String {expr} to a Float. This mostly works the same
as when using a floating point number in an expression, see
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index 21c47edc24..db3eb757c0 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -687,25 +687,17 @@ CTRL-Z Suspend Vim, like ":stop".
Command-line mode, the CTRL-Z is inserted as a normal
character. In Visual mode Vim goes back to Normal
mode.
- Note: if CTRL-Z undoes a change see |mswin.vim|.
-
:sus[pend][!] or *:sus* *:suspend* *:st* *:stop*
-:st[op][!] Suspend Vim.
+:st[op][!] Suspend Vim. Vim will continue if you make it the
+ foreground job again.
If the '!' is not given and 'autowrite' is set, every
buffer with changes and a file name is written out.
If the '!' is given or 'autowrite' is not set, changed
buffers are not written, don't forget to bring Vim
back to the foreground later!
-In the GUI, suspending is implemented as iconising gvim. In Windows 95/NT,
-gvim is minimized.
-
-On many Unix systems, it is possible to suspend Vim with CTRL-Z. This is only
-possible in Normal and Visual mode (see next chapter, |vim-modes|). Vim will
-continue if you make it the foreground job again. On other systems, CTRL-Z
-will start a new shell. This is the same as the ":sh" command. Vim will
-continue if you exit from the shell.
+In the GUI, suspending is implementation-defined.
In X-windows the selection is disowned when Vim suspends. this means you
can't paste it in another application (since Vim is going to sleep an attempt
diff --git a/src/nvim/auevents.lua b/src/nvim/auevents.lua
index 7dfaf54ff0..1153314e76 100644
--- a/src/nvim/auevents.lua
+++ b/src/nvim/auevents.lua
@@ -92,6 +92,8 @@ return {
'VimLeave', -- before exiting Vim
'VimLeavePre', -- before exiting Vim and writing ShaDa file
'VimResized', -- after Vim window was resized
+ 'VimResume', -- after Nvim is resumed
+ 'VimSuspend', -- before Nvim is suspended
'WinNew', -- when entering a new window
'WinEnter', -- after entering a window
'WinLeave', -- before leaving a window
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index 776e2bfa86..4e6ca8d278 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -658,9 +658,9 @@ static void channel_process_exit_cb(Process *proc, int status, void *data)
terminal_close(chan->term, msg);
}
- // if status is -1 the process did not really exit,
- // we just closed the handle onto a detached process
- if (status >= 0) {
+ // If process did not exit, we only closed the handle of a detached process.
+ bool exited = (status >= 0);
+ if (exited) {
process_channel_event(chan, &chan->on_exit, "exit", NULL, 0, status);
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 284185083e..713eb816f8 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -15702,6 +15702,56 @@ static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr)
p_cpo = save_cpo;
}
+/// "stdpath()" helper for list results
+static void get_xdg_var_list(const XDGVarType xdg, typval_T *rettv)
+ FUNC_ATTR_NONNULL_ALL
+{
+ const void *iter = NULL;
+ list_T *const list = tv_list_alloc(kListLenShouldKnow);
+ rettv->v_type = VAR_LIST;
+ rettv->vval.v_list = list;
+ tv_list_ref(list);
+ char *const dirs = stdpaths_get_xdg_var(xdg);
+ do {
+ size_t dir_len;
+ const char *dir;
+ iter = vim_env_iter(':', dirs, iter, &dir, &dir_len);
+ if (dir != NULL && dir_len > 0) {
+ char *dir_with_nvim = xmemdupz(dir, dir_len);
+ dir_with_nvim = concat_fnames_realloc(dir_with_nvim, "nvim", true);
+ tv_list_append_string(list, dir_with_nvim, strlen(dir_with_nvim));
+ xfree(dir_with_nvim);
+ }
+ } while (iter != NULL);
+ xfree(dirs);
+}
+
+/// "stdpath(type)" function
+static void f_stdpath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
+{
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
+
+ const char *const p = tv_get_string_chk(&argvars[0]);
+ if (p == NULL) {
+ return; // Type error; errmsg already given.
+ }
+
+ if (strcmp(p, "config") == 0) {
+ rettv->vval.v_string = (char_u *)get_xdg_home(kXDGConfigHome);
+ } else if (strcmp(p, "data") == 0) {
+ rettv->vval.v_string = (char_u *)get_xdg_home(kXDGDataHome);
+ } else if (strcmp(p, "cache") == 0) {
+ rettv->vval.v_string = (char_u *)get_xdg_home(kXDGCacheHome);
+ } else if (strcmp(p, "config_dirs") == 0) {
+ get_xdg_var_list(kXDGConfigDirs, rettv);
+ } else if (strcmp(p, "data_dirs") == 0) {
+ get_xdg_var_list(kXDGDataDirs, rettv);
+ } else {
+ EMSG2(_("E6100: \"%s\" is not a valid stdpath"), p);
+ }
+}
+
/*
* "str2float()" function
*/
diff --git a/src/nvim/eval.h b/src/nvim/eval.h
index b798eae187..149dae688e 100644
--- a/src/nvim/eval.h
+++ b/src/nvim/eval.h
@@ -10,6 +10,7 @@
#include "nvim/event/rstream.h"
#include "nvim/event/wstream.h"
#include "nvim/channel.h"
+#include "nvim/os/stdpaths_defs.h"
#define COPYID_INC 2
#define COPYID_MASK (~0x1)
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index daa3b637a3..801d2cc468 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -280,6 +280,7 @@ return {
spellsuggest={args={1, 3}},
split={args={1, 3}},
sqrt={args=1, func="float_op_wrapper", data="&sqrt"},
+ stdpath={args=1},
str2float={args=1},
str2nr={args={1, 2}},
strcharpart={args={2, 3}},
diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c
index d92464f17b..7998e0b8d0 100644
--- a/src/nvim/event/loop.c
+++ b/src/nvim/event/loop.c
@@ -21,7 +21,6 @@ void loop_init(Loop *loop, void *data)
loop->recursive = 0;
loop->uv.data = loop;
loop->children = kl_init(WatcherPtr);
- loop->children_stop_requests = 0;
loop->events = multiqueue_new_parent(loop_on_put, loop);
loop->fast_events = multiqueue_new_child(loop->events);
loop->thread_events = multiqueue_new_parent(NULL, NULL);
diff --git a/src/nvim/event/loop.h b/src/nvim/event/loop.h
index d1a40d5cc9..c0e2f49e4f 100644
--- a/src/nvim/event/loop.h
+++ b/src/nvim/event/loop.h
@@ -37,7 +37,6 @@ typedef struct loop {
// generic timer, used by loop_poll_events()
uv_timer_t poll_timer;
- size_t children_stop_requests;
uv_async_t async;
uv_mutex_t mutex;
int recursive;
diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c
index 60650344ce..23433cf495 100644
--- a/src/nvim/event/process.c
+++ b/src/nvim/event/process.c
@@ -23,7 +23,7 @@
#endif
// Time for a process to exit cleanly before we send KILL.
-// For pty processes SIGTERM is sent first (in case SIGHUP was not enough).
+// For PTY processes SIGTERM is sent first (in case SIGHUP was not enough).
#define KILL_TIMEOUT_MS 2000
static bool process_is_tearing_down = false;
@@ -111,6 +111,7 @@ int process_spawn(Process *proc, bool in, bool out, bool err)
proc->internal_close_cb = decref;
proc->refcount++;
kl_push(WatcherPtr, proc->loop->children, proc);
+ DLOG("new: pid=%d argv=[%s]", proc->pid, *proc->argv);
return 0;
}
@@ -188,8 +189,7 @@ int process_wait(Process *proc, int ms, MultiQueue *events)
}
if (proc->refcount == 1) {
- // Job exited, collect status and manually invoke close_cb to free the job
- // resources
+ // Job exited, free its resources.
decref(proc);
if (events) {
// the decref call created an exit event, process it now
@@ -205,11 +205,12 @@ int process_wait(Process *proc, int ms, MultiQueue *events)
/// Ask a process to terminate and eventually kill if it doesn't respond
void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL
{
- if (proc->stopped_time) {
+ bool exited = (proc->status >= 0);
+ if (exited || proc->stopped_time) {
return;
}
-
proc->stopped_time = os_hrtime();
+
switch (proc->type) {
case kProcessTypeUv:
// Close the process's stdin. If the process doesn't close its own
@@ -227,35 +228,32 @@ void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL
abort();
}
- Loop *loop = proc->loop;
- if (!loop->children_stop_requests++) {
- // When there's at least one stop request pending, start a timer that
- // will periodically check if a signal should be send to the job.
- ILOG("starting job kill timer");
- uv_timer_start(&loop->children_kill_timer, children_kill_cb,
- KILL_TIMEOUT_MS, KILL_TIMEOUT_MS);
- }
+ // (Re)start timer to verify that stopped process(es) died.
+ uv_timer_start(&proc->loop->children_kill_timer, children_kill_cb,
+ KILL_TIMEOUT_MS, 0);
}
-/// Iterates the process list sending SIGTERM to stopped processes and SIGKILL
-/// to those that didn't die from SIGTERM after a while(exit_timeout is 0).
+/// Sends SIGKILL (or SIGTERM..SIGKILL for PTY jobs) to processes that did
+/// not terminate after process_stop().
static void children_kill_cb(uv_timer_t *handle)
{
Loop *loop = handle->loop->data;
- uint64_t now = os_hrtime();
kl_iter(WatcherPtr, loop->children, current) {
Process *proc = (*current)->data;
- if (!proc->stopped_time) {
+ bool exited = (proc->status >= 0);
+ if (exited || !proc->stopped_time) {
continue;
}
- uint64_t elapsed = (now - proc->stopped_time) / 1000000 + 1;
-
- if (elapsed >= KILL_TIMEOUT_MS) {
- int sig = proc->type == kProcessTypePty && elapsed < KILL_TIMEOUT_MS * 2
- ? SIGTERM
- : SIGKILL;
- os_proc_tree_kill(proc->pid, sig);
+ uint64_t term_sent = UINT64_MAX == proc->stopped_time;
+ if (kProcessTypePty != proc->type || term_sent) {
+ os_proc_tree_kill(proc->pid, SIGKILL);
+ } else {
+ os_proc_tree_kill(proc->pid, SIGTERM);
+ proc->stopped_time = UINT64_MAX; // Flag: SIGTERM was sent.
+ // Restart timer.
+ uv_timer_start(&proc->loop->children_kill_timer, children_kill_cb,
+ KILL_TIMEOUT_MS, 0);
}
}
}
@@ -383,12 +381,8 @@ static void process_close_handles(void **argv)
static void on_process_exit(Process *proc)
{
Loop *loop = proc->loop;
- if (proc->stopped_time && loop->children_stop_requests
- && !--loop->children_stop_requests) {
- // Stop the timer if no more stop requests are pending
- DLOG("Stopping process kill timer");
- uv_timer_stop(&loop->children_kill_timer);
- }
+ ILOG("exited: pid=%d status=%d stoptime=%" PRIu64, proc->pid, proc->status,
+ proc->stopped_time);
// Process has terminated, but there could still be data to be read from the
// OS. We are still in the libuv loop, so we cannot call code that polls for
diff --git a/src/nvim/event/process.h b/src/nvim/event/process.h
index 033ce3604b..ba2c2a6a11 100644
--- a/src/nvim/event/process.h
+++ b/src/nvim/event/process.h
@@ -19,8 +19,7 @@ struct process {
Loop *loop;
void *data;
int pid, status, refcount;
- // set to the hrtime of when process_stop was called for the process.
- uint64_t stopped_time;
+ uint64_t stopped_time; // process_stop() timestamp
const char *cwd;
char **argv;
Stream in, out, err;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 93cb0e50fa..7cd6dbdeca 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -6300,15 +6300,18 @@ static void ex_stop(exarg_T *eap)
if (!eap->forceit) {
autowrite_all();
}
+ apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, false, NULL);
ui_cursor_goto((int)Rows - 1, 0);
ui_linefeed();
ui_flush();
ui_call_suspend(); // call machine specific function
+
ui_flush();
maketitle();
resettitle(); // force updating the title
redraw_later_clear();
ui_refresh(); // may have resized window
+ apply_autocmds(EVENT_VIMRESUME, NULL, NULL, false, NULL);
}
}
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 25653deb3e..4adff63b95 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -1737,9 +1737,17 @@ failed:
xfree(buffer);
if (read_stdin) {
- /* Use stderr for stdin, makes shell commands work. */
close(0);
+#ifndef WIN32
+ // On Unix, use stderr for stdin, makes shell commands work.
ignored = dup(2);
+#else
+ // On Windows, use the console input handle for stdin.
+ HANDLE conin = CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES)NULL,
+ OPEN_EXISTING, 0, (HANDLE)NULL);
+ ignored = _open_osfhandle(conin, _O_RDONLY);
+#endif
}
if (tmpname != NULL) {
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 4f9a5a979f..a4ed868af1 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -725,9 +725,7 @@ static void init_locale(void)
#endif
-/*
- * Scan the command line arguments.
- */
+/// Scan the command line arguments.
static void command_line_scan(mparm_T *parmp)
{
int argc = parmp->argc;
@@ -897,8 +895,9 @@ static void command_line_scan(mparm_T *parmp)
p_write = FALSE;
break;
- case 'N': /* "-N" Nocompatible */
- /* No-op */
+ case 'N': // "-N" Nocompatible
+ case 'X': // "-X" Do not connect to X server
+ // No-op
break;
case 'n': /* "-n" no swap file */
diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c
index a41fb7c621..866a005228 100644
--- a/src/nvim/os/stdpaths.c
+++ b/src/nvim/os/stdpaths.c
@@ -88,7 +88,7 @@ char *stdpaths_get_xdg_var(const XDGVarType idx)
///
/// In WIN32 get_xdg_home(kXDGDataHome) returns `{xdg_directory}/nvim-data` to
/// avoid storing configuration and data files in the same path.
-static char *get_xdg_home(const XDGVarType idx)
+char *get_xdg_home(const XDGVarType idx)
FUNC_ATTR_WARN_UNUSED_RESULT
{
char *dir = stdpaths_get_xdg_var(idx);
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 276b47536f..cec2e2913f 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -359,6 +359,15 @@ void terminal_resize(Terminal *term, uint16_t width, uint16_t height)
return;
}
+ FOR_ALL_TAB_WINDOWS(tp, wp) {
+ if (wp->w_buffer && wp->w_buffer->terminal == term) {
+ const uint16_t win_width =
+ (uint16_t)(MAX(0, wp->w_width - win_col_off(wp)));
+ width = MAX(width, win_width);
+ height = (uint16_t)MAX(height, wp->w_height);
+ }
+ }
+
vterm_set_size(term->vt, height, width);
vterm_screen_flush_damage(term->vts);
term->pending_resize = true;
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index a31e1843fc..4bfcbf8e79 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -20,13 +20,13 @@ SCRIPTS_DEFAULT = \
test40.out \
test42.out \
test48.out \
- test49.out \
test52.out \
test64.out \
ifneq ($(OS),Windows_NT)
SCRIPTS_DEFAULTS := $(SCRIPTS_DEFAULT) \
test17.out \
+ test49.out \
endif
diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim
index 7090be7726..5c98455909 100644
--- a/src/nvim/testdir/runtest.vim
+++ b/src/nvim/testdir/runtest.vim
@@ -61,7 +61,7 @@ set nomore
lang mess C
" Always use forward slashes.
-set shellslash
+" set shellslash
" Prepare for calling test_garbagecollect_now().
let v:testing = 1
diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim
index 7d6dd0c7ce..aac9fefef4 100644
--- a/src/nvim/testdir/setup.vim
+++ b/src/nvim/testdir/setup.vim
@@ -17,3 +17,11 @@ let &packpath = &rtp
" Make sure $HOME does not get read or written.
let $HOME = '/does/not/exist'
+
+" Use default shell on Windows to avoid segfault, caused by TUI
+if has('win32')
+ let $SHELL = ''
+ let $TERM = ''
+ let &shell = empty($COMSPEC) ? exepath('cmd.exe') : $COMSPEC
+ set shellcmdflag=/s/c shellxquote=\" shellredir=>%s\ 2>&1
+endif
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 673246e1fb..be68e9ff9d 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -154,7 +154,7 @@ func Test_getcompletion()
call assert_equal([], l)
let l = getcompletion('', 'dir')
- call assert_true(index(l, 'sautest/') >= 0)
+ call assert_true(index(l, expand('sautest/')) >= 0)
let l = getcompletion('NoMatch', 'dir')
call assert_equal([], l)
@@ -246,7 +246,7 @@ func Test_getcompletion()
" Command line completion tests
let l = getcompletion('cd ', 'cmdline')
- call assert_true(index(l, 'sautest/') >= 0)
+ call assert_true(index(l, expand('sautest/')) >= 0)
let l = getcompletion('cd NoMatch', 'cmdline')
call assert_equal([], l)
let l = getcompletion('let v:n', 'cmdline')
@@ -288,7 +288,7 @@ func Test_expand_star_star()
call mkdir('a/b', 'p')
call writefile(['asdfasdf'], 'a/b/fileXname')
call feedkeys(":find **/fileXname\<Tab>\<CR>", 'xt')
- call assert_equal('find a/b/fileXname', getreg(':'))
+ call assert_equal('find '.expand('a/b/fileXname'), getreg(':'))
bwipe!
call delete('a', 'rf')
endfunc
diff --git a/src/nvim/testdir/test_find_complete.vim b/src/nvim/testdir/test_find_complete.vim
index 4732109ed0..1019246404 100644
--- a/src/nvim/testdir/test_find_complete.vim
+++ b/src/nvim/testdir/test_find_complete.vim
@@ -3,6 +3,8 @@
" Do all the tests in a separate window to avoid E211 when we recursively
" delete the Xfind directory during cleanup
func Test_find_complete()
+ let shellslash = &shellslash
+ set shellslash
set belloff=all
" On windows a stale "Xfind" directory may exist, remove it so that
@@ -154,4 +156,5 @@ func Test_find_complete()
exe 'cd ' . cwd
call delete('Xfind', 'rf')
set path&
+ let &shellslash = shellslash
endfunc
diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim
index 06c48d8e76..4d4a902031 100644
--- a/src/nvim/testdir/test_help_tagjump.vim
+++ b/src/nvim/testdir/test_help_tagjump.vim
@@ -30,7 +30,7 @@ func Test_help_tagjump()
help sp?it
call assert_equal("help", &filetype)
- call assert_true(getline('.') =~ '\*:split\*')
+ call assert_true(getline('.') =~ '\*'.(has('win32') ? 'split()' : ':split').'\*')
helpclose
help :?
diff --git a/src/nvim/testdir/test_makeencoding.vim b/src/nvim/testdir/test_makeencoding.vim
index a3d5538a47..6e4c7af821 100644
--- a/src/nvim/testdir/test_makeencoding.vim
+++ b/src/nvim/testdir/test_makeencoding.vim
@@ -13,12 +13,19 @@ endif
let s:script = 'test_makeencoding.py'
-let s:message_tbl = {
+if has('iconv')
+ let s:message_tbl = {
\ 'utf-8': 'ÀÈÌÒÙ こんにちは 你好',
\ 'latin1': 'ÀÈÌÒÙ',
\ 'cp932': 'こんにちは',
\ 'cp936': '你好',
\}
+else
+ let s:message_tbl = {
+ \ 'utf-8': 'ÀÈÌÒÙ こんにちは 你好',
+ \ 'latin1': 'ÀÈÌÒÙ',
+ \}
+endif
" Tests for :cgetfile and :lgetfile.
diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim
index a15d15213a..f8c3161b40 100644
--- a/src/nvim/testdir/test_options.vim
+++ b/src/nvim/testdir/test_options.vim
@@ -158,6 +158,8 @@ func Test_set_completion()
call assert_equal('"set fileencodings:ucs-bom,utf-8,default,latin1', @:)
" Expand directories.
+ let shellslash = &shellslash
+ set shellslash
call feedkeys(":set cdpath=./\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_match('./samples/ ', @:)
call assert_notmatch('./small.vim ', @:)
@@ -168,6 +170,7 @@ func Test_set_completion()
call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
+ let &shellslash = shellslash
endfunc
func Test_set_errors()
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index dd177fd633..85f93cf3da 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -850,17 +850,17 @@ func s:dir_stack_tests(cchar)
let qf = g:Xgetlist()
- call assert_equal('dir1/a/habits2.txt', bufname(qf[1].bufnr))
+ call assert_equal(expand('dir1/a/habits2.txt'), bufname(qf[1].bufnr))
call assert_equal(1, qf[1].lnum)
- call assert_equal('dir1/a/b/habits3.txt', bufname(qf[3].bufnr))
+ call assert_equal(expand('dir1/a/b/habits3.txt'), bufname(qf[3].bufnr))
call assert_equal(2, qf[3].lnum)
- call assert_equal('dir1/a/habits2.txt', bufname(qf[4].bufnr))
+ call assert_equal(expand('dir1/a/habits2.txt'), bufname(qf[4].bufnr))
call assert_equal(7, qf[4].lnum)
- call assert_equal('dir1/c/habits4.txt', bufname(qf[6].bufnr))
+ call assert_equal(expand('dir1/c/habits4.txt'), bufname(qf[6].bufnr))
call assert_equal(3, qf[6].lnum)
call assert_equal('habits1.txt', bufname(qf[9].bufnr))
call assert_equal(4, qf[9].lnum)
- call assert_equal('dir2/habits5.txt', bufname(qf[11].bufnr))
+ call assert_equal(expand('dir2/habits5.txt'), bufname(qf[11].bufnr))
call assert_equal(5, qf[11].lnum)
let &efm=save_efm
@@ -1065,7 +1065,7 @@ func Test_efm2()
call assert_equal(8, len(l))
call assert_equal(89, l[4].lnum)
call assert_equal(1, l[4].valid)
- call assert_equal('unittests/dbfacadeTest.py', bufname(l[4].bufnr))
+ call assert_equal(expand('unittests/dbfacadeTest.py'), bufname(l[4].bufnr))
" The following sequence of commands used to crash Vim
set efm=%W%m
@@ -1609,11 +1609,11 @@ func Test_two_windows()
laddexpr 'one.txt:3:one one one'
let loc_one = getloclist(one_id)
- call assert_equal('Xone/a/one.txt', bufname(loc_one[1].bufnr))
+ call assert_equal(expand('Xone/a/one.txt'), bufname(loc_one[1].bufnr))
call assert_equal(3, loc_one[1].lnum)
let loc_two = getloclist(two_id)
- call assert_equal('Xtwo/a/two.txt', bufname(loc_two[1].bufnr))
+ call assert_equal(expand('Xtwo/a/two.txt'), bufname(loc_two[1].bufnr))
call assert_equal(5, loc_two[1].lnum)
call win_gotoid(one_id)
diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim
index 46d884a97c..beecb4cd0d 100644
--- a/src/nvim/testdir/test_recover.vim
+++ b/src/nvim/testdir/test_recover.vim
@@ -6,11 +6,6 @@ func Test_recover_root_dir()
set dir=/
call assert_fails('recover', 'E305:')
close!
-
- if has('win32') || filewritable('/') == 2
- " can write in / directory on MS-Windows
- set dir=/notexist/
- endif
call assert_fails('split Xtest', 'E303:')
set dir&
endfunc
diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim
index 1239fe9427..0a09130b0c 100644
--- a/src/nvim/testdir/test_stat.vim
+++ b/src/nvim/testdir/test_stat.vim
@@ -86,7 +86,7 @@ func Test_win32_symlink_dir()
let res = system('dir C:\Users /a')
if match(res, '\C<SYMLINKD> *All Users') >= 0
" Get the filetype of the symlink.
- call assert_equal('dir', getftype('C:\Users\All Users'))
+ call assert_equal('link', getftype('C:\Users\All Users'))
endif
endif
endfunc
diff --git a/src/nvim/testdir/test_system.vim b/src/nvim/testdir/test_system.vim
index ce9d110d82..d3c0594c03 100644
--- a/src/nvim/testdir/test_system.vim
+++ b/src/nvim/testdir/test_system.vim
@@ -5,14 +5,12 @@ function! Test_System()
return
endif
let out = system('echo 123')
- " On Windows we may get a trailing space.
- if out != "123 \n"
- call assert_equal("123\n", out)
- endif
+ call assert_equal("123\n", out)
let out = systemlist('echo 123')
- " On Windows we may get a trailing space and CR.
- if out != ["123 \r"]
+ if &shell =~# 'cmd.exe$'
+ call assert_equal(["123\r"], out)
+ else
call assert_equal(['123'], out)
endif
diff --git a/test/functional/autocmd/termclose_spec.lua b/test/functional/autocmd/termclose_spec.lua
index 0804579a4f..db4e5379d0 100644
--- a/test/functional/autocmd/termclose_spec.lua
+++ b/test/functional/autocmd/termclose_spec.lua
@@ -32,7 +32,7 @@ describe('TermClose event', function()
end)
it('kills job trapping SIGTERM', function()
- if helpers.pending_win32(pending) then return end
+ if iswin() then return end
nvim('set_option', 'shell', 'sh')
nvim('set_option', 'shellcmdflag', '-c')
command([[ let g:test_job = jobstart('trap "" TERM && echo 1 && sleep 60', { ]]
@@ -51,8 +51,8 @@ describe('TermClose event', function()
ok(duration <= 4000) -- Epsilon for slow CI
end)
- it('kills pty job trapping SIGHUP and SIGTERM', function()
- if helpers.pending_win32(pending) then return end
+ it('kills PTY job trapping SIGHUP and SIGTERM', function()
+ if iswin() then return end
nvim('set_option', 'shell', 'sh')
nvim('set_option', 'shellcmdflag', '-c')
command([[ let g:test_job = jobstart('trap "" HUP TERM && echo 1 && sleep 60', { ]]
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index 24bff423df..e90339b0cd 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -19,14 +19,18 @@ local expect_twostreams = helpers.expect_twostreams
local expect_msg_seq = helpers.expect_msg_seq
local Screen = require('test.functional.ui.screen')
+-- Kill process with given pid
+local function os_kill(pid)
+ return os.execute((iswin()
+ and 'taskkill /f /t /pid '..pid..' > nul'
+ or 'kill -9 '..pid..' > /dev/null'))
+end
+
describe('jobs', function()
local channel
before_each(function()
clear()
- if iswin() then
- helpers.set_shell_powershell()
- end
channel = nvim('get_api_info')[1]
nvim('set_var', 'channel', channel)
source([[
@@ -52,7 +56,7 @@ describe('jobs', function()
it('uses &shell and &shellcmdflag if passed a string', function()
nvim('command', "let $VAR = 'abc'")
if iswin() then
- nvim('command', "let j = jobstart('echo $env:VAR', g:job_opts)")
+ nvim('command', "let j = jobstart('echo %VAR%', g:job_opts)")
else
nvim('command', "let j = jobstart('echo $VAR', g:job_opts)")
end
@@ -64,7 +68,7 @@ describe('jobs', function()
it('changes to given / directory', function()
nvim('command', "let g:job_opts.cwd = '/'")
if iswin() then
- nvim('command', "let j = jobstart('(Get-Location).Path', g:job_opts)")
+ nvim('command', "let j = jobstart('cd', g:job_opts)")
else
nvim('command', "let j = jobstart('pwd', g:job_opts)")
end
@@ -79,7 +83,7 @@ describe('jobs', function()
mkdir(dir)
nvim('command', "let g:job_opts.cwd = '" .. dir .. "'")
if iswin() then
- nvim('command', "let j = jobstart('(Get-Location).Path', g:job_opts)")
+ nvim('command', "let j = jobstart('cd', g:job_opts)")
else
nvim('command', "let j = jobstart('pwd', g:job_opts)")
end
@@ -103,7 +107,7 @@ describe('jobs', function()
local _, err = pcall(function()
nvim('command', "let g:job_opts.cwd = '" .. dir .. "'")
if iswin() then
- nvim('command', "let j = jobstart('pwd|%{$_.Path}', g:job_opts)")
+ nvim('command', "let j = jobstart('cd', g:job_opts)")
else
nvim('command', "let j = jobstart('pwd', g:job_opts)")
end
@@ -134,10 +138,8 @@ describe('jobs', function()
end)
it('invokes callbacks when the job writes and exits', function()
- -- TODO: hangs on Windows
- if helpers.pending_win32(pending) then return end
nvim('command', "let g:job_opts.on_stderr = function('OnEvent')")
- nvim('command', [[call jobstart('echo ""', g:job_opts)]])
+ nvim('command', [[call jobstart(has('win32') ? 'echo:' : 'echo', g:job_opts)]])
expect_twostreams({{'notification', 'stdout', {0, {'', ''}}},
{'notification', 'stdout', {0, {''}}}},
{{'notification', 'stderr', {0, {''}}}})
@@ -145,15 +147,28 @@ describe('jobs', function()
end)
it('allows interactive commands', function()
- if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
- nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
+ nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
neq(0, eval('j'))
nvim('command', 'call jobsend(j, "abc\\n")')
eq({'notification', 'stdout', {0, {'abc', ''}}}, next_msg())
nvim('command', 'call jobsend(j, "123\\nxyz\\n")')
- eq({'notification', 'stdout', {0, {'123', 'xyz', ''}}}, next_msg())
+ expect_msg_seq(
+ { {'notification', 'stdout', {0, {'123', 'xyz', ''}}}
+ },
+ -- Alternative sequence:
+ { {'notification', 'stdout', {0, {'123', ''}}},
+ {'notification', 'stdout', {0, {'xyz', ''}}}
+ }
+ )
nvim('command', 'call jobsend(j, [123, "xyz", ""])')
- eq({'notification', 'stdout', {0, {'123', 'xyz', ''}}}, next_msg())
+ expect_msg_seq(
+ { {'notification', 'stdout', {0, {'123', 'xyz', ''}}}
+ },
+ -- Alternative sequence:
+ { {'notification', 'stdout', {0, {'123', ''}}},
+ {'notification', 'stdout', {0, {'xyz', ''}}}
+ }
+ )
nvim('command', "call jobstop(j)")
eq({'notification', 'stdout', {0, {''}}}, next_msg())
eq({'notification', 'exit', {0, 0}}, next_msg())
@@ -226,16 +241,14 @@ describe('jobs', function()
end)
it('closes the job streams with jobclose', function()
- if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
- nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
+ nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', 'call jobclose(j, "stdin")')
eq({'notification', 'stdout', {0, {''}}}, next_msg())
- eq({'notification', 'exit', {0, 0}}, next_msg())
+ eq({'notification', 'exit', {0, iswin() and 1 or 0}}, next_msg())
end)
it("disallows jobsend on a job that closed stdin", function()
- if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
- nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
+ nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', 'call jobclose(j, "stdin")')
eq(false, pcall(function()
nvim('command', 'call jobsend(j, ["some data"])')
@@ -248,8 +261,7 @@ describe('jobs', function()
end)
it('disallows jobstop twice on the same job', function()
- if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
- nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
+ nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
neq(0, eval('j'))
eq(true, pcall(eval, "jobstop(j)"))
eq(false, pcall(eval, "jobstop(j)"))
@@ -260,41 +272,49 @@ describe('jobs', function()
end)
it('can get the pid value using getpid', function()
- if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
- nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
+ nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
local pid = eval('jobpid(j)')
- eq(0,os.execute('ps -p '..pid..' > /dev/null'))
+ neq(NIL, meths.get_proc(pid))
nvim('command', 'call jobstop(j)')
eq({'notification', 'stdout', {0, {''}}}, next_msg())
- eq({'notification', 'exit', {0, 0}}, next_msg())
- neq(0,os.execute('ps -p '..pid..' > /dev/null'))
+ if iswin() then
+ expect_msg_seq(
+ -- win64
+ { {'notification', 'exit', {0, 1}}
+ },
+ -- win32
+ { {'notification', 'exit', {0, 15}}
+ }
+ )
+ else
+ eq({'notification', 'exit', {0, 0}}, next_msg())
+ end
+ eq(NIL, meths.get_proc(pid))
end)
it("do not survive the exit of nvim", function()
- if helpers.pending_win32(pending) then return end
-- use sleep, which doesn't die on stdin close
- nvim('command', "let g:j = jobstart(['sleep', '1000'], g:job_opts)")
+ nvim('command', "let g:j = jobstart(has('win32') ? ['ping', '-n', '1001', '127.0.0.1'] : ['sleep', '1000'], g:job_opts)")
local pid = eval('jobpid(g:j)')
- eq(0,os.execute('ps -p '..pid..' > /dev/null'))
+ neq(NIL, meths.get_proc(pid))
clear()
- neq(0,os.execute('ps -p '..pid..' > /dev/null'))
+ eq(NIL, meths.get_proc(pid))
end)
it('can survive the exit of nvim with "detach"', function()
- if helpers.pending_win32(pending) then return end
nvim('command', 'let g:job_opts.detach = 1')
- nvim('command', "let g:j = jobstart(['sleep', '1000'], g:job_opts)")
+ nvim('command', "let g:j = jobstart(has('win32') ? ['ping', '-n', '1001', '127.0.0.1'] : ['sleep', '1000'], g:job_opts)")
local pid = eval('jobpid(g:j)')
- eq(0,os.execute('ps -p '..pid..' > /dev/null'))
+ neq(NIL, meths.get_proc(pid))
clear()
- eq(0,os.execute('ps -p '..pid..' > /dev/null'))
+ neq(NIL, meths.get_proc(pid))
-- clean up after ourselves
- os.execute('kill -9 '..pid..' > /dev/null')
+ eq(0, os_kill(pid))
end)
it('can pass user data to the callback', function()
nvim('command', 'let g:job_opts.user = {"n": 5, "s": "str", "l": [1]}')
- nvim('command', [[call jobstart('echo "foo"', g:job_opts)]])
+ nvim('command', [[call jobstart('echo foo', g:job_opts)]])
local data = {n = 5, s = 'str', l = {1}}
expect_msg_seq(
{ {'notification', 'stdout', {data, {'foo', ''}}},
@@ -312,14 +332,14 @@ describe('jobs', function()
it('can omit data callbacks', function()
nvim('command', 'unlet g:job_opts.on_stdout')
nvim('command', 'let g:job_opts.user = 5')
- nvim('command', [[call jobstart('echo "foo"', g:job_opts)]])
+ nvim('command', [[call jobstart('echo foo', g:job_opts)]])
eq({'notification', 'exit', {5, 0}}, next_msg())
end)
it('can omit exit callback', function()
nvim('command', 'unlet g:job_opts.on_exit')
nvim('command', 'let g:job_opts.user = 5')
- nvim('command', [[call jobstart('echo "foo"', g:job_opts)]])
+ nvim('command', [[call jobstart('echo foo', g:job_opts)]])
expect_msg_seq(
{ {'notification', 'stdout', {5, {'foo', ''} } },
{'notification', 'stdout', {5, {''} } },
@@ -401,15 +421,14 @@ describe('jobs', function()
end)
it('does not repeat output with slow output handlers', function()
- if helpers.pending_win32(pending) then return end
source([[
let d = {'data': []}
function! d.on_stdout(job, data, event) dict
- call add(self.data, a:data)
+ call add(self.data, Normalize(a:data))
sleep 200m
endfunction
if has('win32')
- let cmd = '1,2,3,4,5 | foreach-object -process {echo $_; sleep 0.1}'
+ let cmd = 'for /L %I in (1,1,5) do @(echo %I& ping -n 2 127.0.0.1 > nul)'
else
let cmd = ['sh', '-c', 'for i in $(seq 1 5); do echo $i; sleep 0.1; done']
endif
@@ -428,7 +447,7 @@ describe('jobs', function()
endfunction
let Callback = function('PrintArgs', ["foo", "bar"])
let g:job_opts = {'on_stdout': Callback}
- call jobstart('echo "some text"', g:job_opts)
+ call jobstart('echo some text', g:job_opts)
]])
expect_msg_seq(
{ {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}},
@@ -448,7 +467,7 @@ describe('jobs', function()
return {id, data, event -> rpcnotify(g:channel, '1', a1, a2, Normalize(data), event)}
endfun
let g:job_opts = {'on_stdout': MkFun()}
- call jobstart('echo "some text"', g:job_opts)
+ call jobstart('echo some text', g:job_opts)
]])
expect_msg_seq(
{ {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}},
@@ -463,7 +482,7 @@ describe('jobs', function()
it('jobstart() works when closure passed directly to `jobstart`', function()
source([[
let g:job_opts = {'on_stdout': {id, data, event -> rpcnotify(g:channel, '1', 'foo', 'bar', Normalize(data), event)}}
- call jobstart('echo "some text"', g:job_opts)
+ call jobstart('echo some text', g:job_opts)
]])
expect_msg_seq(
{ {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}},
@@ -476,9 +495,20 @@ describe('jobs', function()
end)
describe('jobwait', function()
+ before_each(function()
+ if iswin() then
+ helpers.set_shell_powershell()
+ end
+ end)
+
it('returns a list of status codes', function()
source([[
- call rpcnotify(g:channel, 'wait', jobwait([
+ call rpcnotify(g:channel, 'wait', jobwait(has('win32') ? [
+ \ jobstart('Start-Sleep -Milliseconds 100; exit 4'),
+ \ jobstart('Start-Sleep -Milliseconds 300; exit 5'),
+ \ jobstart('Start-Sleep -Milliseconds 500; exit 6'),
+ \ jobstart('Start-Sleep -Milliseconds 700; exit 7')
+ \ ] : [
\ jobstart('sleep 0.10; exit 4'),
\ jobstart('sleep 0.110; exit 5'),
\ jobstart('sleep 0.210; exit 6'),
@@ -498,7 +528,12 @@ describe('jobs', function()
endif
let g:exits += 1
endfunction
- call jobwait([
+ call jobwait(has('win32') ? [
+ \ jobstart('Start-Sleep -Milliseconds 100; exit 5', g:dict),
+ \ jobstart('Start-Sleep -Milliseconds 300; exit 5', g:dict),
+ \ jobstart('Start-Sleep -Milliseconds 500; exit 5', g:dict),
+ \ jobstart('Start-Sleep -Milliseconds 700; exit 5', g:dict)
+ \ ] : [
\ jobstart('sleep 0.010; exit 5', g:dict),
\ jobstart('sleep 0.030; exit 5', g:dict),
\ jobstart('sleep 0.050; exit 5', g:dict),
@@ -511,7 +546,12 @@ describe('jobs', function()
it('will return status codes in the order of passed ids', function()
source([[
- call rpcnotify(g:channel, 'wait', jobwait([
+ call rpcnotify(g:channel, 'wait', jobwait(has('win32') ? [
+ \ jobstart('Start-Sleep -Milliseconds 700; exit 4'),
+ \ jobstart('Start-Sleep -Milliseconds 500; exit 5'),
+ \ jobstart('Start-Sleep -Milliseconds 300; exit 6'),
+ \ jobstart('Start-Sleep -Milliseconds 100; exit 7')
+ \ ] : [
\ jobstart('sleep 0.070; exit 4'),
\ jobstart('sleep 0.050; exit 5'),
\ jobstart('sleep 0.030; exit 6'),
@@ -525,7 +565,7 @@ describe('jobs', function()
source([[
call rpcnotify(g:channel, 'wait', jobwait([
\ -10,
- \ jobstart('sleep 0.01; exit 5'),
+ \ jobstart((has('win32') ? 'Start-Sleep -Milliseconds 100' : 'sleep 0.01').'; exit 5'),
\ ]))
]])
eq({'notification', 'wait', {{-3, 5}}}, next_msg())
@@ -534,7 +574,9 @@ describe('jobs', function()
it('will return -2 when interrupted without timeout', function()
feed_command('call rpcnotify(g:channel, "ready") | '..
'call rpcnotify(g:channel, "wait", '..
- 'jobwait([jobstart("sleep 10; exit 55")]))')
+ 'jobwait([jobstart("'..
+ (iswin() and 'Start-Sleep 10' or 'sleep 10')..
+ '; exit 55")]))')
eq({'notification', 'ready', {}}, next_msg())
feed('<c-c>')
eq({'notification', 'wait', {{-2}}}, next_msg())
@@ -543,7 +585,9 @@ describe('jobs', function()
it('will return -2 when interrupted with timeout', function()
feed_command('call rpcnotify(g:channel, "ready") | '..
'call rpcnotify(g:channel, "wait", '..
- 'jobwait([jobstart("sleep 10; exit 55")], 10000))')
+ 'jobwait([jobstart("'..
+ (iswin() and 'Start-Sleep 10' or 'sleep 10')..
+ '; exit 55")], 10000))')
eq({'notification', 'ready', {}}, next_msg())
feed('<c-c>')
eq({'notification', 'wait', {{-2}}}, next_msg())
@@ -598,20 +642,22 @@ describe('jobs', function()
end)
describe('with timeout argument', function()
- if helpers.pending_win32(pending) then return end
it('will return -1 if the wait timed out', function()
source([[
call rpcnotify(g:channel, 'wait', jobwait([
\ jobstart('exit 4'),
- \ jobstart('sleep 10; exit 5'),
- \ ], 100))
+ \ jobstart((has('win32') ? 'Start-Sleep 10' : 'sleep 10').'; exit 5'),
+ \ ], has('win32') ? 3000 : 100))
]])
eq({'notification', 'wait', {{4, -1}}}, next_msg())
end)
it('can pass 0 to check if a job exists', function()
source([[
- call rpcnotify(g:channel, 'wait', jobwait([
+ call rpcnotify(g:channel, 'wait', jobwait(has('win32') ? [
+ \ jobstart('Start-Sleep -Milliseconds 50; exit 4'),
+ \ jobstart('Start-Sleep -Milliseconds 300; exit 5'),
+ \ ] : [
\ jobstart('sleep 0.05; exit 4'),
\ jobstart('sleep 0.3; exit 5'),
\ ], 0))
@@ -633,10 +679,9 @@ describe('jobs', function()
end)
it('cannot have both rpc and pty options', function()
- if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
command("let g:job_opts.pty = v:true")
command("let g:job_opts.rpc = v:true")
- local _, err = pcall(command, "let j = jobstart(['cat', '-'], g:job_opts)")
+ local _, err = pcall(command, "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
ok(string.find(err, "E475: Invalid argument: job cannot have both 'pty' and 'rpc' options set") ~= nil)
end)
@@ -656,19 +701,16 @@ describe('jobs', function()
end)
it('jobstop() kills entire process tree #6530', function()
- command('set shell& shellcmdflag& shellquote& shellpipe& shellredir& shellxquote&')
-
-- XXX: Using `nvim` isn't a good test, it reaps its children on exit.
-- local c = 'call jobstart([v:progpath, "-u", "NONE", "-i", "NONE", "--headless"])'
-- local j = eval("jobstart([v:progpath, '-u', 'NONE', '-i', 'NONE', '--headless', '-c', '"
-- ..c.."', '-c', '"..c.."'])")
-- Create child with several descendants.
- local j = (iswin()
- and eval([=[jobstart('start /b cmd /c "ping 127.0.0.1 -n 1 -w 30000 > NUL"]=]
- ..[=[ & start /b cmd /c "ping 127.0.0.1 -n 1 -w 40000 > NUL"]=]
- ..[=[ & start /b cmd /c "ping 127.0.0.1 -n 1 -w 50000 > NUL"')]=])
- or eval("jobstart('sleep 30 | sleep 30 | sleep 30')"))
+ local sleep_cmd = (iswin()
+ and 'ping -n 31 127.0.0.1'
+ or 'sleep 30')
+ local j = eval("jobstart('"..sleep_cmd..' | '..sleep_cmd..' | '..sleep_cmd.."')")
local ppid = funcs.jobpid(j)
local children
retry(nil, nil, function()
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua
index 201426c40b..23cea4c038 100644
--- a/test/functional/eval/system_spec.lua
+++ b/test/functional/eval/system_spec.lua
@@ -255,10 +255,8 @@ describe('system()', function()
end
end)
it('to backgrounded command does not crash', function()
- -- cmd.exe doesn't background a command with &
- if iswin() then return end
-- This is indeterminate, just exercise the codepath. May get E5677.
- feed_command('call system("echo -n echoed &")')
+ feed_command('call system(has("win32") ? "start /b /wait cmd /c echo echoed" : "echo -n echoed &")')
local v_errnum = string.match(eval("v:errmsg"), "^E%d*:")
if v_errnum then
eq("E5677:", v_errnum)
@@ -272,10 +270,8 @@ describe('system()', function()
eq("input", eval('system("cat -", "input")'))
end)
it('to backgrounded command does not crash', function()
- -- cmd.exe doesn't background a command with &
- if iswin() then return end
-- This is indeterminate, just exercise the codepath. May get E5677.
- feed_command('call system("cat - &", "input")')
+ feed_command('call system(has("win32") ? "start /b /wait more" : "cat - &", "input")')
local v_errnum = string.match(eval("v:errmsg"), "^E%d*:")
if v_errnum then
eq("E5677:", v_errnum)
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index bf11042dd6..03c6f3bbaa 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -427,7 +427,7 @@ end
local function set_shell_powershell()
source([[
set shell=powershell shellquote=( shellpipe=\| shellredir=> shellxquote=
- set shellcmdflag=-NoLogo\ -NoProfile\ -ExecutionPolicy\ RemoteSigned\ -Command
+ let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command Remove-Item -Force alias:sleep;'
]])
end
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index 9e29baba2d..f452cafd22 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -5,12 +5,15 @@ local Screen = require('test.functional.ui.screen')
local meths = helpers.meths
local command = helpers.command
local clear = helpers.clear
+local exc_exec = helpers.exc_exec
local eval = helpers.eval
local eq = helpers.eq
+local funcs = helpers.funcs
local insert = helpers.insert
local neq = helpers.neq
local mkdir = helpers.mkdir
local rmdir = helpers.rmdir
+local alter_slashes = helpers.alter_slashes
describe('startup defaults', function()
describe(':filetype', function()
@@ -422,3 +425,276 @@ describe('XDG-based defaults', function()
end)
end)
end)
+
+
+describe('stdpath()', function()
+ context('returns a String', function()
+ describe('with "config"' , function ()
+ it('knows XDG_CONFIG_HOME', function()
+ clear({env={
+ XDG_CONFIG_HOME=alter_slashes('/home/docwhat/.config'),
+ }})
+ eq(alter_slashes('/home/docwhat/.config/nvim'), funcs.stdpath('config'))
+ end)
+
+ it('handles changes during runtime', function()
+ clear({env={
+ XDG_CONFIG_HOME=alter_slashes('/home/original'),
+ }})
+ eq(alter_slashes('/home/original/nvim'), funcs.stdpath('config'))
+ command("let $XDG_CONFIG_HOME='"..alter_slashes('/home/new').."'")
+ eq(alter_slashes('/home/new/nvim'), funcs.stdpath('config'))
+ end)
+
+ it("doesn't expand $VARIABLES", function()
+ clear({env={
+ XDG_CONFIG_HOME='$VARIABLES',
+ VARIABLES='this-should-not-happen',
+ }})
+ eq(alter_slashes('$VARIABLES/nvim'), funcs.stdpath('config'))
+ end)
+
+ it("doesn't expand ~/", function()
+ clear({env={
+ XDG_CONFIG_HOME=alter_slashes('~/frobnitz'),
+ }})
+ eq(alter_slashes('~/frobnitz/nvim'), funcs.stdpath('config'))
+ end)
+ end)
+
+ describe('with "data"' , function ()
+ local appended_dir
+ setup(function()
+ -- Windows appends 'nvim-data' instead of just 'nvim' to
+ -- prevent collisions due to XDG_CONFIG_HOME and XDG_DATA_HOME
+ -- being the same.
+ if helpers.iswin() then
+ appended_dir = '/nvim-data'
+ else
+ appended_dir = '/nvim'
+ end
+ end)
+
+ it('knows XDG_DATA_HOME', function()
+ clear({env={
+ XDG_DATA_HOME=alter_slashes('/home/docwhat/.local'),
+ }})
+ eq(alter_slashes('/home/docwhat/.local' .. appended_dir), funcs.stdpath('data'))
+ end)
+
+ it('handles changes during runtime', function()
+ clear({env={
+ XDG_DATA_HOME=alter_slashes('/home/original'),
+ }})
+ eq(alter_slashes('/home/original' .. appended_dir), funcs.stdpath('data'))
+ command("let $XDG_DATA_HOME='"..alter_slashes('/home/new').."'")
+ eq(alter_slashes('/home/new' .. appended_dir), funcs.stdpath('data'))
+ end)
+
+ it("doesn't expand $VARIABLES", function()
+ clear({env={
+ XDG_DATA_HOME='$VARIABLES',
+ VARIABLES='this-should-not-happen',
+ }})
+ eq(alter_slashes('$VARIABLES' .. appended_dir), funcs.stdpath('data'))
+ end)
+
+ it("doesn't expand ~/", function()
+ clear({env={
+ XDG_DATA_HOME=alter_slashes('~/frobnitz'),
+ }})
+ eq(alter_slashes('~/frobnitz' .. appended_dir), funcs.stdpath('data'))
+ end)
+ end)
+
+ describe('with "cache"' , function ()
+ it('knows XDG_CACHE_HOME', function()
+ clear({env={
+ XDG_CACHE_HOME=alter_slashes('/home/docwhat/.cache'),
+ }})
+ eq(alter_slashes('/home/docwhat/.cache/nvim'), funcs.stdpath('cache'))
+ end)
+
+ it('handles changes during runtime', function()
+ clear({env={
+ XDG_CACHE_HOME=alter_slashes('/home/original'),
+ }})
+ eq(alter_slashes('/home/original/nvim'), funcs.stdpath('cache'))
+ command("let $XDG_CACHE_HOME='"..alter_slashes('/home/new').."'")
+ eq(alter_slashes('/home/new/nvim'), funcs.stdpath('cache'))
+ end)
+
+ it("doesn't expand $VARIABLES", function()
+ clear({env={
+ XDG_CACHE_HOME='$VARIABLES',
+ VARIABLES='this-should-not-happen',
+ }})
+ eq(alter_slashes('$VARIABLES/nvim'), funcs.stdpath('cache'))
+ end)
+
+ it("doesn't expand ~/", function()
+ clear({env={
+ XDG_CACHE_HOME=alter_slashes('~/frobnitz'),
+ }})
+ eq(alter_slashes('~/frobnitz/nvim'), funcs.stdpath('cache'))
+ end)
+ end)
+ end)
+
+ context('returns a List', function()
+ -- Some OS specific variables the system would have set.
+ local function base_env()
+ if helpers.iswin() then
+ return {
+ HOME='C:\\Users\\docwhat', -- technically, is not a usual PATH
+ HOMEDRIVE='C:',
+ HOMEPATH='\\Users\\docwhat',
+ LOCALAPPDATA='C:\\Users\\docwhat\\AppData\\Local',
+ TEMP='C:\\Users\\docwhat\\AppData\\Local\\Temp',
+ TMPDIR='C:\\Users\\docwhat\\AppData\\Local\\Temp',
+ TMP='C:\\Users\\docwhat\\AppData\\Local\\Temp',
+ }
+ else
+ return {
+ HOME='/home/docwhat',
+ HOMEDRIVE='HOMEDRIVE-should-be-ignored',
+ HOMEPATH='HOMEPATH-should-be-ignored',
+ LOCALAPPDATA='LOCALAPPDATA-should-be-ignored',
+ TEMP='TEMP-should-be-ignored',
+ TMPDIR='TMPDIR-should-be-ignored',
+ TMP='TMP-should-be-ignored',
+ }
+ end
+ end
+
+ local function set_paths_via_system(var_name, paths)
+ local env = base_env()
+ env[var_name] = table.concat(paths, ':')
+ clear({env=env})
+ end
+
+ local function set_paths_at_runtime(var_name, paths)
+ clear({env=base_env()})
+ meths.set_var('env_val', table.concat(paths, ':'))
+ command(('let $%s=g:env_val'):format(var_name))
+ end
+
+ local function behaves_like_dir_list_env(msg, stdpath_arg, env_var_name, paths, expected_paths)
+ describe(msg, function()
+ it('set via system', function()
+ set_paths_via_system(env_var_name, paths)
+ eq(expected_paths, funcs.stdpath(stdpath_arg))
+ end)
+
+ it('set at runtime', function()
+ set_paths_at_runtime(env_var_name, paths)
+ eq(expected_paths, funcs.stdpath(stdpath_arg))
+ end)
+ end)
+ end
+
+ describe('with "config_dirs"' , function ()
+ behaves_like_dir_list_env(
+ 'handles XDG_CONFIG_DIRS with one path',
+ 'config_dirs', 'XDG_CONFIG_DIRS',
+ {
+ alter_slashes('/home/docwhat/.config')
+ },
+ {
+ alter_slashes('/home/docwhat/.config/nvim')
+ })
+
+ behaves_like_dir_list_env(
+ 'handles XDG_CONFIG_DIRS with two paths',
+ 'config_dirs', 'XDG_CONFIG_DIRS',
+ {
+ alter_slashes('/home/docwhat/.config'),
+ alter_slashes('/etc/config')
+ },
+ {
+ alter_slashes('/home/docwhat/.config/nvim'),
+ alter_slashes('/etc/config/nvim')
+ })
+
+ behaves_like_dir_list_env(
+ "doesn't expand $VAR and $IBLES",
+ 'config_dirs', 'XDG_CONFIG_DIRS',
+ { '$HOME', '$TMP' },
+ {
+ alter_slashes('$HOME/nvim'),
+ alter_slashes('$TMP/nvim')
+ })
+
+
+ behaves_like_dir_list_env(
+ "doesn't expand ~/",
+ 'config_dirs', 'XDG_CONFIG_DIRS',
+ {
+ alter_slashes('~/.oldconfig'),
+ alter_slashes('~/.olderconfig')
+ },
+ {
+ alter_slashes('~/.oldconfig/nvim'),
+ alter_slashes('~/.olderconfig/nvim')
+ })
+ end)
+
+ describe('with "data_dirs"' , function ()
+ behaves_like_dir_list_env(
+ 'knows XDG_DATA_DIRS with one path',
+ 'data_dirs', 'XDG_DATA_DIRS',
+ {
+ alter_slashes('/home/docwhat/.data')
+ },
+ {
+ alter_slashes('/home/docwhat/.data/nvim')
+ })
+
+ behaves_like_dir_list_env(
+ 'knows XDG_DATA_DIRS with two paths',
+ 'data_dirs', 'XDG_DATA_DIRS',
+ {
+ alter_slashes('/home/docwhat/.data'),
+ alter_slashes('/etc/local')
+ },
+ {
+ alter_slashes('/home/docwhat/.data/nvim'),
+ alter_slashes('/etc/local/nvim'),
+ })
+
+ behaves_like_dir_list_env(
+ "doesn't expand $VAR and $IBLES",
+ 'data_dirs', 'XDG_DATA_DIRS',
+ { '$HOME', '$TMP' },
+ {
+ alter_slashes('$HOME/nvim'),
+ alter_slashes('$TMP/nvim')
+ })
+
+ behaves_like_dir_list_env(
+ "doesn't expand ~/",
+ 'data_dirs', 'XDG_DATA_DIRS',
+ {
+ alter_slashes('~/.oldconfig'),
+ alter_slashes('~/.olderconfig')
+ },
+ {
+ alter_slashes('~/.oldconfig/nvim'),
+ alter_slashes('~/.olderconfig/nvim'),
+ })
+ end)
+ end)
+
+ describe('errors', function()
+ it('on unknown strings', function()
+ eq('Vim(call):E6100: "capybara" is not a valid stdpath', exc_exec('call stdpath("capybara")'))
+ eq('Vim(call):E6100: "" is not a valid stdpath', exc_exec('call stdpath("")'))
+ eq('Vim(call):E6100: "23" is not a valid stdpath', exc_exec('call stdpath(23)'))
+ end)
+
+ it('on non-strings', function()
+ eq('Vim(call):E731: using Dictionary as a String', exc_exec('call stdpath({"eris": 23})'))
+ eq('Vim(call):E730: using List as a String', exc_exec('call stdpath([23])'))
+ end)
+ end)
+end)
diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua
index a21d9f0a56..263a5ce79d 100644
--- a/test/functional/terminal/mouse_spec.lua
+++ b/test/functional/terminal/mouse_spec.lua
@@ -101,7 +101,7 @@ describe('terminal mouse', function()
line28 │line28 |
line29 │line29 |
line30 │line30 |
- rows: 5, cols: 24 │rows: 5, cols: 24 |
+ rows: 5, cols: 25 │rows: 5, cols: 25 |
{2:^ } │{2: } |
========== ========== |
:vsp |
@@ -111,7 +111,7 @@ describe('terminal mouse', function()
{7: 1 }^ │line28 |
{4:~ }│line29 |
{4:~ }│line30 |
- {4:~ }│rows: 5, cols: 24 |
+ {4:~ }│rows: 5, cols: 25 |
{4:~ }│{2: } |
========== ========== |
:enew | set number |
@@ -121,7 +121,7 @@ describe('terminal mouse', function()
{7: 27 }line │line28 |
{7: 28 }line │line29 |
{7: 29 }line │line30 |
- {7: 30 }line │rows: 5, cols: 24 |
+ {7: 30 }line │rows: 5, cols: 25 |
{7: 31 }^ │{2: } |
========== ========== |
|
@@ -131,7 +131,7 @@ describe('terminal mouse', function()
{7: 27 }line │line28 |
{7: 28 }line │line29 |
{7: 29 }line │line30 |
- {7: 30 }line │rows: 5, cols: 24 |
+ {7: 30 }line │rows: 5, cols: 25 |
{7: 31 } │{1: } |
========== ========== |
{3:-- TERMINAL --} |
@@ -142,7 +142,7 @@ describe('terminal mouse', function()
screen:expect([[
{7: 27 }line │line29 |
{7: 28 }line │line30 |
- {7: 29 }line │rows: 5, cols: 24 |
+ {7: 29 }line │rows: 5, cols: 25 |
{7: 30 }line │mouse enabled |
{7: 31 } │{1: } |
========== ========== |
@@ -155,7 +155,7 @@ describe('terminal mouse', function()
screen:expect([[
{7: 21 }line │line29 |
{7: 22 }line │line30 |
- {7: 23 }line │rows: 5, cols: 24 |
+ {7: 23 }line │rows: 5, cols: 25 |
{7: 24 }line │mouse enabled |
{7: 25 }line │{1: } |
========== ========== |
@@ -165,7 +165,7 @@ describe('terminal mouse', function()
screen:expect([[
{7: 26 }line │line29 |
{7: 27 }line │line30 |
- {7: 28 }line │rows: 5, cols: 24 |
+ {7: 28 }line │rows: 5, cols: 25 |
{7: 29 }line │mouse enabled |
{7: 30 }line │{1: } |
========== ========== |
@@ -178,7 +178,7 @@ describe('terminal mouse', function()
screen:expect([[
{7: 27 }line │line29 |
{7: 28 }l^ine │line30 |
- {7: 29 }line │rows: 5, cols: 24 |
+ {7: 29 }line │rows: 5, cols: 25 |
{7: 30 }line │mouse enabled |
{7: 31 } │{2: } |
========== ========== |
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 2f9abfd3f6..0ae5802a01 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -387,15 +387,7 @@ describe('tui FocusGained/FocusLost', function()
-- Exit cmdline-mode. Redraws from timers/events are blocked during
-- cmdline-mode, so the buffer won't be updated until we exit cmdline-mode.
feed_data('\n')
- screen:expect([[
- {1: } |
- lost |
- gained |
- {4:~ }|
- {5:[No Name] [+] }|
- : |
- {3:-- TERMINAL --} |
- ]])
+ screen:expect('lost'..(' '):rep(46)..'\ngained', nil, nil, nil, true)
end)
end)
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index 8a1f9b0d19..7fafd6b352 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -4,6 +4,7 @@ local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.cl
local feed, command = helpers.feed, helpers.command
local insert = helpers.insert
local eq = helpers.eq
+local eval = helpers.eval
local iswin = helpers.iswin
describe('screen', function()
@@ -75,11 +76,26 @@ describe('Screen', function()
local function check()
eq(true, screen.suspended)
end
+
+ command('let g:ev = []')
+ command('autocmd VimResume * :call add(g:ev, "r")')
+ command('autocmd VimSuspend * :call add(g:ev, "s")')
+
+ eq(false, screen.suspended)
command('suspend')
+ eq({ 's', 'r' }, eval('g:ev'))
+
screen:expect(check)
screen.suspended = false
+
feed('<c-z>')
+ eq({ 's', 'r', 's', 'r' }, eval('g:ev'))
+
screen:expect(check)
+ screen.suspended = false
+
+ command('suspend')
+ eq({ 's', 'r', 's', 'r', 's', 'r' }, eval('g:ev'))
end)
end)