aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/edit.c1
-rw-r--r--src/nvim/eval.c3
-rw-r--r--src/nvim/ex_cmds.c5
-rw-r--r--src/nvim/ex_docmd.c4
-rw-r--r--src/nvim/ex_getln.c7
-rw-r--r--src/nvim/farsi.c9
-rw-r--r--src/nvim/fileio.c27
-rw-r--r--src/nvim/getchar.c4
-rw-r--r--src/nvim/macros.h12
-rw-r--r--src/nvim/main.c47
-rw-r--r--src/nvim/memline.c16
-rw-r--r--src/nvim/memory.c1
-rw-r--r--src/nvim/menu.c1
-rw-r--r--src/nvim/message.c40
-rw-r--r--src/nvim/misc1.c3
-rw-r--r--src/nvim/misc2.c37
-rw-r--r--src/nvim/msgpack_rpc/remote_ui.c12
-rw-r--r--src/nvim/normal.c3
-rw-r--r--src/nvim/option.c2
-rw-r--r--src/nvim/os/event.h3
-rw-r--r--src/nvim/os/input.c6
-rw-r--r--src/nvim/os/shell.c6
-rw-r--r--src/nvim/os_unix.c10
-rw-r--r--src/nvim/os_unix_defs.h4
-rw-r--r--src/nvim/path.c7
-rw-r--r--src/nvim/regexp_nfa.c2
-rw-r--r--src/nvim/screen.c6
-rw-r--r--src/nvim/search.c3
-rw-r--r--src/nvim/syntax.c15
-rw-r--r--src/nvim/tag.c2
-rw-r--r--src/nvim/testdir/Makefile45
-rw-r--r--src/nvim/testdir/test19.in33
-rw-r--r--src/nvim/testdir/test19.ok10
-rw-r--r--src/nvim/testdir/test63.in195
-rw-r--r--src/nvim/testdir/test63.ok16
-rw-r--r--src/nvim/testdir/test89.in71
-rw-r--r--src/nvim/testdir/test89.ok28
-rw-r--r--src/nvim/tui/tui.c46
-rw-r--r--src/nvim/ui.c19
-rw-r--r--src/nvim/ui.h4
-rw-r--r--src/nvim/undo.c1
-rw-r--r--src/nvim/version.c42
-rw-r--r--src/nvim/vim.h7
43 files changed, 231 insertions, 584 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 14b3968f2d..516278f34d 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1400,7 +1400,6 @@ void display_dollar(colnr_T col)
if (!redrawing())
return;
- ui_cursor_off();
save_col = curwin->w_cursor.col;
curwin->w_cursor.col = col;
if (has_mbyte) {
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index ae8e0d329f..a716bb66ab 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -7287,8 +7287,7 @@ static void f_browse(typval_T *argvars, typval_T *rettv)
*/
static void f_browsedir(typval_T *argvars, typval_T *rettv)
{
- rettv->vval.v_string = NULL;
- rettv->v_type = VAR_STRING;
+ f_browse(argvars, rettv);
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 739243cbee..12a634416b 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -42,7 +42,6 @@
#include "nvim/memline.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
-#include "nvim/misc2.h"
#include "nvim/garray.h"
#include "nvim/memory.h"
#include "nvim/move.h"
@@ -1063,9 +1062,7 @@ do_filter (
/* Create the shell command in allocated memory. */
cmd_buf = make_filter_cmd(cmd, itmp, otmp);
-
ui_cursor_goto((int)Rows - 1, 0);
- ui_cursor_on();
/*
* When not redirecting the output the command can write anything to the
@@ -1248,7 +1245,6 @@ do_shell (
// This ui_cursor_goto is required for when the '\n' resulted in a "delete line
// 1" command to the terminal.
ui_cursor_goto(msg_row, msg_col);
- ui_cursor_on();
(void)call_shell(cmd, flags, NULL);
did_check_timestamps = FALSE;
need_check_timestamps = TRUE;
@@ -1963,7 +1959,6 @@ void print_line(linenr_T lnum, int use_number, int list)
print_line_no_prefix(lnum, use_number, list);
if (save_silent) {
msg_putchar('\n');
- ui_cursor_on(); /* msg_start() switches it off */
ui_flush();
silent_mode = save_silent;
}
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 8167824a41..63d94dabc0 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -6381,9 +6381,7 @@ static void ex_sleep(exarg_T *eap)
void do_sleep(long msec)
{
long done;
-
- ui_cursor_on();
- ui_flush();
+ ui_flush(); // flush before waiting
for (done = 0; !got_int && done < msec; done += 1000L) {
os_delay(msec - done > 1000L ? 1000L : msec - done, true);
os_breakcheck();
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index a7bb4afa70..d5f7a218f4 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1364,7 +1364,7 @@ cmdline_changed:
if (ccline.cmdlen == 0)
i = 0;
else {
- ui_cursor_off(); /* so the user knows we're busy */
+ ui_busy_start();
ui_flush();
++emsg_off; /* So it doesn't beep if bad expr */
/* Set the time limit to half a second. */
@@ -1382,6 +1382,7 @@ cmdline_changed:
} else if (char_avail())
/* cancelled searching because a char was typed */
incsearch_postponed = TRUE;
+ ui_busy_stop();
}
if (i != 0)
highlight_match = TRUE; /* highlight position */
@@ -1701,10 +1702,6 @@ getexmodeline (
char_u *p;
int prev_char;
- /* Switch cursor on now. This avoids that it happens after the "\n", which
- * confuses the system function that computes tabstops. */
- ui_cursor_on();
-
/* always start in column 0; write a newline if necessary */
compute_cmdrow();
if ((msg_col || msg_didout) && promptc != '?')
diff --git a/src/nvim/farsi.c b/src/nvim/farsi.c
index db167825ce..2ca581ebd3 100644
--- a/src/nvim/farsi.c
+++ b/src/nvim/farsi.c
@@ -1561,9 +1561,6 @@ int fkmap(int c)
if (!curwin->w_cursor.col) {
return ALEF_U_H;
}
- }
-
- if (!p_ri) {
dec_cursor();
}
@@ -1595,9 +1592,6 @@ int fkmap(int c)
if (!curwin->w_cursor.col) {
return ALEF;
}
- }
-
- if (!p_ri) {
dec_cursor();
}
@@ -1673,9 +1667,6 @@ int fkmap(int c)
if (!curwin->w_cursor.col) {
return TEE;
}
- }
-
- if (!p_ri) {
dec_cursor();
}
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 24fe547e56..9d4c990f3a 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -1729,14 +1729,14 @@ failed:
}
}
- if (set_options)
- save_file_ff(curbuf); /* remember the current file format */
-
- /* If editing a new file: set 'fenc' for the current buffer.
- * Also for ":read ++edit file". */
- if (set_options)
+ if (set_options) {
+ // Remember the current file format.
+ save_file_ff(curbuf);
+ // If editing a new file: set 'fenc' for the current buffer.
+ // Also for ":read ++edit file".
set_string_option_direct((char_u *)"fenc", -1, fenc,
- OPT_FREE|OPT_LOCAL, 0);
+ OPT_FREE | OPT_LOCAL, 0);
+ }
if (fenc_alloced)
free(fenc);
# ifdef USE_ICONV
@@ -5878,19 +5878,20 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
is_buflocal = FALSE;
buflocal_nr = 0;
- if (patlen >= 7 && STRNCMP(pat, "<buffer", 7) == 0
+ if (patlen >= 8 && STRNCMP(pat, "<buffer", 7) == 0
&& pat[patlen - 1] == '>') {
- /* Error will be printed only for addition. printing and removing
- * will proceed silently. */
+ /* "<buffer...>": Error will be printed only for addition.
+ * printing and removing will proceed silently. */
is_buflocal = TRUE;
if (patlen == 8)
+ /* "<buffer>" */
buflocal_nr = curbuf->b_fnum;
else if (patlen > 9 && pat[7] == '=') {
- /* <buffer=abuf> */
- if (patlen == 13 && STRNICMP(pat, "<buffer=abuf>", 13))
+ if (patlen == 13 && STRNICMP(pat, "<buffer=abuf>", 13) == 0)
+ /* "<buffer=abuf>" */
buflocal_nr = autocmd_bufnr;
- /* <buffer=123> */
else if (skipdigits(pat + 8) == pat + patlen - 1)
+ /* "<buffer=123>" */
buflocal_nr = atoi((char *)pat + 8);
}
}
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index b3e274d952..96ce586a9e 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -2379,8 +2379,8 @@ inchar (
int retesc = FALSE; /* return ESC with gotint */
int script_char;
- if (wait_time == -1L || wait_time > 100L) { /* flush output before waiting */
- ui_cursor_on();
+ if (wait_time == -1L || wait_time > 100L) {
+ // flush output before waiting
ui_flush();
}
diff --git a/src/nvim/macros.h b/src/nvim/macros.h
index 7dd8120d09..653f46fb44 100644
--- a/src/nvim/macros.h
+++ b/src/nvim/macros.h
@@ -97,15 +97,9 @@
*/
#define vim_isbreak(c) (breakat_flags[(char_u)(c)])
-#ifdef BINARY_FILE_IO
-# define WRITEBIN "wb" /* no CR-LF translation */
-# define READBIN "rb"
-# define APPENDBIN "ab"
-#else
-# define WRITEBIN "w"
-# define READBIN "r"
-# define APPENDBIN "a"
-#endif
+#define WRITEBIN "wb" /* no CR-LF translation */
+#define READBIN "rb"
+#define APPENDBIN "ab"
# define mch_fopen(n, p) fopen((n), (p))
diff --git a/src/nvim/main.c b/src/nvim/main.c
index a4f430e811..2f1e6e6d3b 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -268,6 +268,23 @@ int main(int argc, char **argv)
/* Set the break level after the terminal is initialized. */
debug_break_level = params.use_debug_break_level;
+ bool reading_input = !params.headless && (params.input_isatty
+ || params.output_isatty || params.err_isatty);
+
+ if (reading_input) {
+ // Its possible that one of the startup commands(arguments, sourced scripts
+ // or plugins) will prompt the user, so start reading from a tty stream
+ // now.
+ int fd = fileno(stdin);
+ if (!params.input_isatty || params.edit_type == EDIT_STDIN) {
+ // use stderr or stdout since stdin is not a tty and/or could be used to
+ // read the file we'll edit when the "-" argument is given(eg: cat file |
+ // nvim -)
+ fd = params.err_isatty ? fileno(stderr) : fileno(stdout);
+ }
+ input_start_stdin(fd);
+ }
+
/* Execute --cmd arguments. */
exe_pre_commands(&params);
@@ -351,19 +368,19 @@ int main(int argc, char **argv)
if (params.edit_type == EDIT_STDIN && !recoverymode)
read_stdin();
- if (!params.headless && (params.output_isatty || params.err_isatty)) {
- if (params.input_isatty && (need_wait_return || msg_didany)) {
- // Since at this point there's no UI instance running yet, error messages
- // would have been printed to stdout. Before starting (which can result
- // in a alternate screen buffer being shown) we need confirmation that
- // the user has seen the messages and that is done with a call to
- // wait_return. For that to work, stdin must be openend temporarily.
- input_start_stdin();
- wait_return(TRUE);
- TIME_MSG("waiting for return");
- input_stop_stdin();
- }
+ if (reading_input && (need_wait_return || msg_didany)) {
+ // Since at this point there's no UI instance running yet, error messages
+ // would have been printed to stdout. Before starting (which can result in
+ // a alternate screen buffer being shown) we need confirmation that the
+ // user has seen the messages and that is done with a call to wait_return.
+ TIME_MSG("waiting for return");
+ wait_return(TRUE);
+ }
+
+ if (!params.headless) {
+ // Stop reading from stdin, the UI layer will take over now
+ input_stop_stdin();
ui_builtin_start();
}
@@ -641,7 +658,6 @@ main_loop (
curwin->w_valid &= ~VALID_CROW;
}
setcursor();
- ui_cursor_on();
do_redraw = FALSE;
@@ -1456,11 +1472,6 @@ static void check_tty(mparm_T *parmp)
TIME_MSG("Warning delay");
}
-
- if (parmp->edit_type != EDIT_STDIN && !parmp->input_isatty) {
- // read commands from directly from stdin
- input_start_stdin();
- }
}
/*
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 1dc3a27415..5a577c6378 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -1277,7 +1277,6 @@ recover_names (
int num_files;
int file_count = 0;
char_u **files;
- int i;
char_u *dirp;
char_u *dir_name;
char_u *fname_res = NULL;
@@ -1357,12 +1356,13 @@ recover_names (
}
}
- /* check for out-of-memory */
- for (i = 0; i < num_names; ++i) {
+ // check for out-of-memory
+ for (int i = 0; i < num_names; ++i) {
if (names[i] == NULL) {
- for (i = 0; i < num_names; ++i)
- free(names[i]);
+ for (int j = 0; j < num_names; ++j)
+ free(names[j]);
num_names = 0;
+ break;
}
}
if (num_names == 0)
@@ -1394,7 +1394,7 @@ recover_names (
*/
if (curbuf->b_ml.ml_mfp != NULL
&& (p = curbuf->b_ml.ml_mfp->mf_fname) != NULL) {
- for (i = 0; i < num_files; ++i)
+ for (int i = 0; i < num_files; ++i)
if (path_full_compare(p, files[i], TRUE) & kEqualFiles) {
/* Remove the name from files[i]. Move further entries
* down. When the array becomes empty free it here, since
@@ -1427,7 +1427,7 @@ recover_names (
}
if (num_files) {
- for (i = 0; i < num_files; ++i) {
+ for (int i = 0; i < num_files; ++i) {
/* print the swap file name */
msg_outnum((long)++file_count);
MSG_PUTS(". ");
@@ -1441,7 +1441,7 @@ recover_names (
} else
file_count += num_files;
- for (i = 0; i < num_names; ++i)
+ for (int i = 0; i < num_names; ++i)
free(names[i]);
if (num_files > 0)
FreeWild(num_files, files);
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index cb9ad97749..2223b65a93 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -7,7 +7,6 @@
#include <stdbool.h>
#include "nvim/vim.h"
-#include "nvim/misc2.h"
#include "nvim/eval.h"
#include "nvim/memfile.h"
#include "nvim/memory.h"
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index 2b1bc3b721..95cc33e4d9 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -1474,7 +1474,6 @@ void ex_menutranslate(exarg_T *eap)
tp->to = to;
} else {
free(from);
- free(from_noamp);
free(to);
}
}
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 3a68de8881..b2e9488388 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -325,7 +325,6 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
}
/*
- * Automatic prototype generation does not understand this function.
* Note: Caller of smgs() and smsg_attr() must check the resulting string is
* shorter than IOSIZE!!!
*/
@@ -581,13 +580,44 @@ int emsg2(char_u *s, char_u *a1)
return emsg3(s, a1, NULL);
}
-/* emsg3() and emsgn() are in misc2.c to avoid warnings for the prototypes. */
-
void emsg_invreg(int name)
{
EMSG2(_("E354: Invalid register name: '%s'"), transchar(name));
}
+/// Print an error message with one or two "%s" and one or two string arguments.
+int emsg3(char_u *s, char_u *a1, char_u *a2)
+{
+ if (emsg_not_now()) {
+ return TRUE; // no error messages at the moment
+ }
+
+ vim_snprintf((char *)IObuff, IOSIZE, (char *)s, a1, a2);
+ return emsg(IObuff);
+}
+
+/// Print an error message with one "%" PRId64 and one (int64_t) argument.
+int emsgn(char_u *s, int64_t n)
+{
+ if (emsg_not_now()) {
+ return TRUE; // no error messages at the moment
+ }
+
+ vim_snprintf((char *)IObuff, IOSIZE, (char *)s, n);
+ return emsg(IObuff);
+}
+
+/// Print an error message with one "%" PRIu64 and one (uint64_t) argument.
+int emsgu(char_u *s, uint64_t n)
+{
+ if (emsg_not_now()) {
+ return TRUE; // no error messages at the moment
+ }
+
+ vim_snprintf((char *)IObuff, IOSIZE, (char *)s, n);
+ return emsg(IObuff);
+}
+
/*
* 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.
@@ -998,7 +1028,6 @@ void msg_start(void)
msg_starthere();
if (msg_silent == 0) {
msg_didout = FALSE; /* no output on current line yet */
- ui_cursor_off();
}
/* when redirecting, may need to start a new line. */
@@ -3052,9 +3081,6 @@ static double tv_float(typval_T *tvs, int *idxp)
* "typval_T". When the latter is not used it must be NULL.
*/
-/* When generating prototypes all of this is skipped, cproto doesn't
- * understand this. */
-
/* Like vim_vsnprintf() but append to the string. */
int vim_snprintf_add(char *str, size_t str_m, char *fmt, ...)
{
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 3ed6b416d6..c9f3fbd511 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -2364,9 +2364,8 @@ int get_keystroke(void)
mapped_ctrl_c = FALSE; /* mappings are not used here */
for (;; ) {
- ui_cursor_on();
+ // flush output before waiting
ui_flush();
-
/* Leave some room for check_termcode() to insert a key code into (max
* 5 chars plus NUL). And fix_input_buffer() can triple the number of
* bytes. */
diff --git a/src/nvim/misc2.c b/src/nvim/misc2.c
index be5150fdc0..fafce66c5f 100644
--- a/src/nvim/misc2.c
+++ b/src/nvim/misc2.c
@@ -297,7 +297,6 @@ int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg)
smsg((char_u *)_("Calling shell to execute: \"%s\""),
cmd == NULL ? p_sh : cmd);
ui_putc('\n');
- ui_cursor_on();
verbose_leave();
}
@@ -390,42 +389,6 @@ int vim_chdir(char_u *new_dir)
return r;
}
-
-/*
- * Print an error message with one or two "%s" and one or two string arguments.
- * This is not in message.c to avoid a warning for prototypes.
- */
-int emsg3(char_u *s, char_u *a1, char_u *a2)
-{
- if (emsg_not_now())
- return TRUE; /* no error messages at the moment */
- vim_snprintf((char *)IObuff, IOSIZE, (char *)s, a1, a2);
- return emsg(IObuff);
-}
-
-/*
- * Print an error message with one "%" PRId64 and one (int64_t) argument.
- * This is not in message.c to avoid a warning for prototypes.
- */
-int emsgn(char_u *s, int64_t n)
-{
- if (emsg_not_now())
- return TRUE; /* no error messages at the moment */
- vim_snprintf((char *)IObuff, IOSIZE, (char *)s, n);
- return emsg(IObuff);
-}
-
-/*
- * Print an error message with one "%" PRIu64 and one (uint64_t) argument.
- */
-int emsgu(char_u *s, uint64_t n)
-{
- if (emsg_not_now())
- return TRUE; /* no error messages at the moment */
- vim_snprintf((char *)IObuff, IOSIZE, (char *)s, n);
- return emsg(IObuff);
-}
-
/*
* Read 2 bytes from "fd" and turn them into an int, MSB first.
*/
diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c
index 45b3dee0fd..b554d76bed 100644
--- a/src/nvim/msgpack_rpc/remote_ui.c
+++ b/src/nvim/msgpack_rpc/remote_ui.c
@@ -82,8 +82,8 @@ static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id,
ui->clear = remote_ui_clear;
ui->eol_clear = remote_ui_eol_clear;
ui->cursor_goto = remote_ui_cursor_goto;
- ui->cursor_on = remote_ui_cursor_on;
- ui->cursor_off = remote_ui_cursor_off;
+ ui->busy_start = remote_ui_busy_start;
+ ui->busy_stop = remote_ui_busy_stop;
ui->mouse_on = remote_ui_mouse_on;
ui->mouse_off = remote_ui_mouse_off;
ui->insert_mode = remote_ui_insert_mode;
@@ -190,16 +190,16 @@ static void remote_ui_cursor_goto(UI *ui, int row, int col)
push_call(ui, "cursor_goto", args);
}
-static void remote_ui_cursor_on(UI *ui)
+static void remote_ui_busy_start(UI *ui)
{
Array args = ARRAY_DICT_INIT;
- push_call(ui, "cursor_on", args);
+ push_call(ui, "busy_start", args);
}
-static void remote_ui_cursor_off(UI *ui)
+static void remote_ui_busy_stop(UI *ui)
{
Array args = ARRAY_DICT_INIT;
- push_call(ui, "cursor_off", args);
+ push_call(ui, "busy_stop", args);
}
static void remote_ui_mouse_on(UI *ui)
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 4c62b0c28d..a708aca136 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -983,7 +983,6 @@ getcount:
free(kmsg);
}
setcursor();
- ui_cursor_on();
ui_flush();
if (msg_scroll || emsg_on_display)
os_delay(1000L, true); /* wait at least one second */
@@ -2998,8 +2997,6 @@ static void display_showcmd(void)
{
int len;
- ui_cursor_off();
-
len = (int)STRLEN(showcmd_buf);
if (len == 0)
showcmd_is_clear = true;
diff --git a/src/nvim/option.c b/src/nvim/option.c
index a9e271517d..98584d1567 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -64,7 +64,6 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
-#include "nvim/misc2.h"
#include "nvim/keymap.h"
#include "nvim/garray.h"
#include "nvim/cursor_shape.h"
@@ -3042,7 +3041,6 @@ theend:
silent_mode = FALSE;
info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
msg_putchar('\n');
- ui_cursor_on(); /* msg_start() switches it off */
ui_flush();
silent_mode = TRUE;
info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
diff --git a/src/nvim/os/event.h b/src/nvim/os/event.h
index f8139e978d..db02b38c7f 100644
--- a/src/nvim/os/event.h
+++ b/src/nvim/os/event.h
@@ -8,7 +8,7 @@
#include "nvim/os/job_defs.h"
#include "nvim/os/time.h"
-// Poll for events until a condition is true or a timeout has passed
+// Poll for events until a condition or timeout
#define event_poll_until(timeout, condition) \
do { \
int remaining = timeout; \
@@ -31,4 +31,5 @@
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os/event.h.generated.h"
#endif
+
#endif // NVIM_OS_EVENT_H
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index 00efa28161..a409a9ed13 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -46,7 +46,7 @@ void input_init(void)
input_buffer = rbuffer_new(INPUT_BUFFER_SIZE + MAX_KEY_CODE_LEN);
}
-void input_start_stdin(void)
+void input_start_stdin(int fd)
{
if (read_stream) {
return;
@@ -54,7 +54,7 @@ void input_start_stdin(void)
read_buffer = rbuffer_new(READ_BUFFER_SIZE);
read_stream = rstream_new(read_cb, read_buffer, NULL);
- rstream_set_file(read_stream, fileno(stdin));
+ rstream_set_file(read_stream, fd);
rstream_start(read_stream);
}
@@ -69,7 +69,7 @@ void input_stop_stdin(void)
read_stream = NULL;
}
-// Low level input function.
+// Low level input function
int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt)
{
if (rbuffer_pending(input_buffer)) {
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index 8cf7e7161d..6fcb62a5f3 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -99,7 +99,6 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_args)
char *output = NULL, **output_ptr = NULL;
int current_state = State;
bool forward_output = true;
- ui_flush();
// While the child is running, ignore terminating signals
signal_reject_deadly();
@@ -239,7 +238,12 @@ static int shell(const char *cmd,
job_close_in(job);
}
+ // invoke busy_start here so event_poll_until wont change the busy state for
+ // the UI
+ ui_busy_start();
+ ui_flush();
status = job_wait(job, -1);
+ ui_busy_stop();
// prepare the out parameters if requested
if (output) {
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index 5d8b4ad26a..8e4569033a 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -232,15 +232,7 @@ void mch_exit(int r)
{
exiting = TRUE;
- {
- ui_builtin_stop();
-
- // Cursor may have been switched off without calling starttermcap()
- // when doing "vim -u vimrc" and vimrc contains ":q". */
- if (full_screen) {
- ui_cursor_on();
- }
- }
+ ui_builtin_stop();
ui_flush();
ml_close_all(TRUE); /* remove all memfiles */
diff --git a/src/nvim/os_unix_defs.h b/src/nvim/os_unix_defs.h
index e5ab9fd4f7..4ffd23aa25 100644
--- a/src/nvim/os_unix_defs.h
+++ b/src/nvim/os_unix_defs.h
@@ -182,10 +182,6 @@
/* Special wildcards that need to be handled by the shell */
#define SPECIAL_WILDCHAR "`'{"
-#ifndef HAVE_OPENDIR
-# define NO_EXPANDPATH
-#endif
-
/*
* Unix has plenty of memory, use large buffers
*/
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 361a4a57f0..346be9108d 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -401,8 +401,6 @@ char_u *save_absolute_path(const char_u *name)
}
-#if !defined(NO_EXPANDPATH)
-
#if defined(UNIX)
/*
* Unix style wildcard expansion code.
@@ -1234,7 +1232,6 @@ addfile (
add_pathsep(p);
GA_APPEND(char_u *, gap, p);
}
-#endif /* !NO_EXPANDPATH */
/*
* Converts a file name into a canonical form. It simplifies a file name into
@@ -1608,7 +1605,6 @@ int same_directory(char_u *f1, char_u *f2)
&& pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0;
}
-#if !defined(NO_EXPANDPATH)
/*
* Compare path "p[]" to "q[]".
* If "maxlen" >= 0 compare "p[maxlen]" to "q[maxlen]"
@@ -1673,9 +1669,7 @@ int pathcmp(const char *p, const char *q, int maxlen)
return -1; /* no match */
return 1;
}
-#endif
-#ifndef NO_EXPANDPATH
/*
* Expand a path into all matching files and/or directories. Handles "*",
* "?", "[a-z]", "**", etc.
@@ -1688,7 +1682,6 @@ int mch_expandpath(garray_T *gap, char_u *path, int flags)
{
return unix_expandpath(gap, path, 0, flags, FALSE);
}
-#endif
/// Try to find a shortname by comparing the fullname with the current
/// directory.
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index fec7100703..6ed42303ef 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -5322,7 +5322,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
if (ireg_icombine && len == 0) {
/* If \Z was present, then ignore composing characters.
* When ignoring the base character this always matches. */
- if (len == 0 && sta->c != curc)
+ if (sta->c != curc)
result = FAIL;
else
result = OK;
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 757bdb34b1..04a092c4f7 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -416,7 +416,6 @@ void update_screen(int type)
search_hl.rm.regprog = NULL;
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->w_redr_type != 0) {
- ui_cursor_off();
if (!did_one) {
did_one = TRUE;
start_search_hl();
@@ -426,7 +425,6 @@ void update_screen(int type)
/* redraw status line after the window to minimize cursor movement */
if (wp->w_redr_status) {
- ui_cursor_off();
win_redr_status(wp);
}
}
@@ -521,7 +519,6 @@ void update_single_line(win_T *wp, linenr_T lnum)
*/
static void update_prepare(void)
{
- ui_cursor_off();
updating_screen = TRUE;
start_search_hl();
}
@@ -6566,7 +6563,6 @@ int showmode(void)
/* Position on the last line in the window, column 0 */
msg_pos_mode();
- ui_cursor_off();
attr = hl_attr(HLF_CM); /* Highlight mode */
if (do_mode) {
MSG_PUTS_ATTR("--", attr);
@@ -7015,7 +7011,6 @@ static void win_redr_ruler(win_T *wp, int always)
|| wp->w_buffer->b_ml.ml_line_count != wp->w_ru_line_count
|| wp->w_topfill != wp->w_ru_topfill
|| empty_line != wp->w_ru_empty) {
- ui_cursor_off();
int width;
int row;
@@ -7238,7 +7233,6 @@ void screen_resize(int width, int height)
setcursor();
}
}
- ui_cursor_on(); /* redrawing may have switched it off */
}
ui_flush();
--busy;
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 6e2824bc8e..f62aeabd72 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -2044,7 +2044,6 @@ showmatch (
p_siso = 0; /* don't use 'sidescrolloff' here */
showruler(FALSE);
setcursor();
- ui_cursor_on(); /* make sure that the cursor is shown */
ui_flush();
/* Restore dollar_vcol(), because setcursor() may call curs_rows()
* which resets it if the matching position is in a previous line
@@ -4253,7 +4252,7 @@ search_line:
* looking for a define). A line starting with "# define"
* is not considered to be a comment line.
*/
- if (!define_matched && skip_comments) {
+ if (skip_comments) {
if ((*line != '#' ||
STRNCMP(skipwhite(line + 1), "define", 6) != 0)
&& get_leader_len(line, NULL, FALSE, TRUE))
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 07f18bf93b..3f9466fd7c 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -5938,15 +5938,22 @@ init_highlight (
int i;
char **pp;
static int had_both = FALSE;
- char_u *p;
/*
* Try finding the color scheme file. Used when a color file was loaded
* and 'background' or 't_Co' is changed.
*/
- p = get_var_value((char_u *)"g:colors_name");
- if (p != NULL && load_colors(p) == OK)
- return;
+ char_u *p = get_var_value((char_u *)"g:colors_name");
+ if (p != NULL) {
+ // Value of g:colors_name could be freed in load_colors() and make
+ // p invalid, so copy it.
+ char_u *copy_p = vim_strsave(p);
+ bool okay = load_colors(copy_p);
+ free(copy_p);
+ if (okay) {
+ return;
+ }
+ }
/*
* Didn't use a color file, use the compiled-in colors.
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 1bb18bee6e..361afb7e07 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -223,7 +223,7 @@ do_tag (
/*
* Don't add a tag to the tagstack if 'tagstack' has been reset.
*/
- if ((!p_tgst && *tag != NUL)) {
+ if (!p_tgst && *tag != NUL) {
use_tagstack = FALSE;
new_tag = TRUE;
} else {
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index afa4ce67f4..8e0f853446 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -9,35 +9,28 @@ SCRIPTSOURCE := ../../../runtime
SCRIPTS := test_autoformat_join.out \
test_eval.out \
- test2.out test3.out test4.out test5.out \
- test6.out test7.out test8.out test9.out test10.out \
- test11.out test12.out test13.out test14.out test15.out \
- test17.out test18.out test19.out test20.out \
- test21.out test22.out test23.out test24.out test25.out \
- test26.out test27.out test28.out test29.out test30.out \
- test31.out test32.out test33.out test34.out test35.out \
+ test3.out \
+ test8.out test10.out \
+ test11.out test12.out test13.out test14.out \
+ test17.out \
+ test24.out \
+ test26.out test27.out test29.out test30.out \
+ test31.out test32.out test34.out \
test36.out test37.out test38.out test39.out test40.out \
- test41.out test42.out test43.out test44.out test45.out \
+ test42.out test43.out test44.out test45.out \
test46.out test47.out test48.out test49.out \
- test51.out test52.out test53.out test54.out test55.out \
- test56.out test57.out test58.out test59.out test60.out \
+ test52.out test53.out test55.out \
+ test57.out test58.out test59.out test60.out \
test61.out test62.out test63.out test64.out test65.out \
- test66.out test67.out test68.out test69.out test70.out \
- test71.out test72.out test73.out test74.out test75.out \
- test76.out test77.out test78.out test79.out test80.out \
- test81.out test82.out test83.out test84.out test85.out \
- test86.out test87.out test88.out test89.out test90.out \
- test91.out test92.out test93.out test94.out test95.out \
- test96.out test97.out test98.out test99.out test100.out \
- test101.out test102.out test103.out test104.out test105.out \
- test106.out test107.out \
- test_options.out \
- test_listlbr.out test_listlbr_utf8.out \
- test_changelist.out \
- test_qf_title.out \
- test_breakindent.out \
- test_insertcount.out \
- test_utf8.out
+ test68.out test69.out test70.out \
+ test71.out test73.out test74.out \
+ test76.out test78.out test79.out test80.out \
+ test82.out test83.out test85.out \
+ test86.out test87.out test88.out \
+ test92.out test93.out test94.out \
+ test96.out test99.out \
+ test_listlbr.out \
+ test_breakindent.out
SCRIPTS_GUI := test16.out
diff --git a/src/nvim/testdir/test19.in b/src/nvim/testdir/test19.in
deleted file mode 100644
index aafa34e521..0000000000
--- a/src/nvim/testdir/test19.in
+++ /dev/null
@@ -1,33 +0,0 @@
-Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set.
-Also test that dv_ works correctly
-
-STARTTEST
-:so small.vim
-:set smarttab expandtab ts=8 sw=4
-:" make sure that backspace works, no matter what termcap is used
-:set t_kD=x7f t_kb=x08
-/some
-r :set noexpandtab
-/other
-r
-:" Test replacing with Tabs and then backspacing to undo it
-0wR 
-:" Test replacing with Tabs
-0wR 
-:" Test that copyindent works with expandtab set
-:set expandtab smartindent copyindent ts=8 sw=8 sts=8
-o{
-x:set nosol
-/Second line/
-fwdv_:?^start?,$w! test.out
-:qa!
-ENDTEST
-
-start text
- some test text
-test text
- other test text
- a cde
- f ghi
-test text
- Second line beginning with whitespace
diff --git a/src/nvim/testdir/test19.ok b/src/nvim/testdir/test19.ok
deleted file mode 100644
index 4146214919..0000000000
--- a/src/nvim/testdir/test19.ok
+++ /dev/null
@@ -1,10 +0,0 @@
-start text
- ome test text
-test text
- ther test text
- a cde
- hi
-test text
-{
- x
- with whitespace
diff --git a/src/nvim/testdir/test63.in b/src/nvim/testdir/test63.in
deleted file mode 100644
index 7fbe0ac434..0000000000
--- a/src/nvim/testdir/test63.in
+++ /dev/null
@@ -1,195 +0,0 @@
-Test for ":match", ":2match", ":3match", "clearmatches()", "getmatches()",
-"matchadd()", "matchaddpos()", "matcharg()", "matchdelete()", and "setmatches()".
-
-STARTTEST
-:so small.vim
-:set encoding=utf8
-:" --- Check that "matcharg()" returns the correct group and pattern if a match
-:" --- is defined.
-:let @r = "*** Test 1: "
-:highlight MyGroup1 term=bold ctermbg=red guibg=red
-:highlight MyGroup2 term=italic ctermbg=green guibg=green
-:highlight MyGroup3 term=underline ctermbg=blue guibg=blue
-:match MyGroup1 /TODO/
-:2match MyGroup2 /FIXME/
-:3match MyGroup3 /XXX/
-:if matcharg(1) == ['MyGroup1', 'TODO'] && matcharg(2) == ['MyGroup2', 'FIXME'] && matcharg(3) == ['MyGroup3', 'XXX']
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED\n"
-:endif
-:" --- Check that "matcharg()" returns an empty list if the argument is not 1,
-:" --- 2 or 3 (only 0 and 4 are tested).
-:let @r .= "*** Test 2: "
-:if matcharg(0) == [] && matcharg(4) == []
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED\n"
-:endif
-:" --- Check that "matcharg()" returns ['', ''] if a match is not defined.
-:let @r .= "*** Test 3: "
-:match
-:2match
-:3match
-:if matcharg(1) == ['', ''] && matcharg(2) == ['', ''] && matcharg(3) == ['', '']
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED\n"
-:endif
-:" --- Check that "matchadd()" and "getmatches()" agree on added matches and
-:" --- that default values apply.
-:let @r .= "*** Test 4: "
-:let m1 = matchadd("MyGroup1", "TODO")
-:let m2 = matchadd("MyGroup2", "FIXME", 42)
-:let m3 = matchadd("MyGroup3", "XXX", 60, 17)
-:if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 4}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 42, 'id': 5}, {'group': 'MyGroup3', 'pattern': 'XXX', 'priority': 60, 'id': 17}]
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED\n"
-:endif
-:" --- Check that "matchdelete()" deletes the matches defined in the previous
-:" --- test correctly.
-:let @r .= "*** Test 5: "
-:call matchdelete(m1)
-:call matchdelete(m2)
-:call matchdelete(m3)
-:unlet m1
-:unlet m2
-:unlet m3
-:if getmatches() == []
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED\n"
-:endif
-:" --- Check that "matchdelete()" returns 0 if successful and otherwise -1.
-:let @r .= "*** Test 6: "
-:let m = matchadd("MyGroup1", "TODO")
-:let r1 = matchdelete(m)
-:let r2 = matchdelete(42)
-:if r1 == 0 && r2 == -1
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED\n"
-:endif
-:unlet m
-:unlet r1
-:unlet r2
-:" --- Check that "clearmatches()" clears all matches defined by ":match" and
-:" --- "matchadd()".
-:let @r .= "*** Test 7: "
-:let m1 = matchadd("MyGroup1", "TODO")
-:let m2 = matchadd("MyGroup2", "FIXME", 42)
-:let m3 = matchadd("MyGroup3", "XXX", 60, 17)
-:match MyGroup1 /COFFEE/
-:2match MyGroup2 /HUMPPA/
-:3match MyGroup3 /VIM/
-:call clearmatches()
-:if getmatches() == []
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED\n"
-:endif
-:unlet m1
-:unlet m2
-:unlet m3
-:" --- Check that "setmatches()" restores a list of matches saved by
-:" --- "getmatches()" without changes. (Matches with equal priority must also
-:" --- remain in the same order.)
-:let @r .= "*** Test 8: "
-:let m1 = matchadd("MyGroup1", "TODO")
-:let m2 = matchadd("MyGroup2", "FIXME", 42)
-:let m3 = matchadd("MyGroup3", "XXX", 60, 17)
-:match MyGroup1 /COFFEE/
-:2match MyGroup2 /HUMPPA/
-:3match MyGroup3 /VIM/
-:let ml = getmatches()
-:call clearmatches()
-:call setmatches(ml)
-:if getmatches() == ml
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED\n"
-:endif
-:call clearmatches()
-:unlet m1
-:unlet m2
-:unlet m3
-:unlet ml
-:" --- Check that "setmatches()" will not add two matches with the same ID. The
-:" --- expected behaviour (for now) is to add the first match but not the
-:" --- second and to return 0 (even though it is a matter of debate whether
-:" --- this can be considered successful behaviour).
-:let @r .= "*** Test 9: "
-:let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])
-:if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}] && r1 == 0
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED\n"
-:endif
-:call clearmatches()
-:unlet r1
-:" --- Check that "setmatches()" returns 0 if successful and otherwise -1.
-:" --- (A range of valid and invalid input values are tried out to generate the
-:" --- return values.)
-:let @r .= "*** Test 10: "
-:let rs1 = setmatches([])
-:let rs2 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])
-:call clearmatches()
-:let rf1 = setmatches(0)
-:let rf2 = setmatches([0])
-:let rf3 = setmatches([{'wrong key': 'wrong value'}])
-:if rs1 == 0 && rs2 == 0 && rf1 == -1 && rf2 == -1 && rf3 == -1
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED\n"
-:endif
-:unlet rs1
-:unlet rs2
-:unlet rf1
-:unlet rf2
-:unlet rf3
-:" --- Check that "matchaddpos()" positions matches correctly
-:let @r .= "*** Test 11:\n"
-:set nolazyredraw
-:call setline(1, 'abcdefghijklmnopq')
-:call matchaddpos("MyGroup1", [[1, 5], [1, 8, 3]], 10, 3)
-:1
-:redraw!
-:let v1 = screenattr(1, 1)
-:let v5 = screenattr(1, 5)
-:let v6 = screenattr(1, 6)
-:let v8 = screenattr(1, 8)
-:let v10 = screenattr(1, 10)
-:let v11 = screenattr(1, 11)
-:let @r .= string(getmatches())."\n"
-:if v1 != v5 && v6 == v1 && v8 == v5 && v10 == v5 && v11 == v1
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED: " . v5 . "/" . v6 . "/" . v8 . "/" . v10 . "/" . v11 . "\n"
-:endif
-:call clearmatches()
-:"
-:call setline(1, 'abcdΣabcdef')
-:call matchaddpos("MyGroup1", [[1, 4, 2], [1, 9, 2]])
-:1
-:redraw!
-:let v1 = screenattr(1, 1)
-:let v4 = screenattr(1, 4)
-:let v5 = screenattr(1, 5)
-:let v6 = screenattr(1, 6)
-:let v7 = screenattr(1, 7)
-:let v8 = screenattr(1, 8)
-:let v9 = screenattr(1, 9)
-:let v10 = screenattr(1, 10)
-:let @r .= string(getmatches())."\n"
-:if v1 != v4 && v5 == v4 && v6 == v1 && v7 == v1 && v8 == v4 && v9 == v4 && v10 == v1
-: let @r .= "OK\n"
-:else
-: let @r .= "FAILED: " . v4 . "/" . v5 . "/" . v6 . "/" . v7 . "/" . v8 . "/" . v9 . "/" . v10 . "\n"
-:endif
-:call clearmatches()
-G"rp
-:/^Results/,$wq! test.out
-ENDTEST
-
-Results of test63:
diff --git a/src/nvim/testdir/test63.ok b/src/nvim/testdir/test63.ok
deleted file mode 100644
index 5d619395b7..0000000000
--- a/src/nvim/testdir/test63.ok
+++ /dev/null
@@ -1,16 +0,0 @@
-Results of test63:
-*** Test 1: OK
-*** Test 2: OK
-*** Test 3: OK
-*** Test 4: OK
-*** Test 5: OK
-*** Test 6: OK
-*** Test 7: OK
-*** Test 8: OK
-*** Test 9: OK
-*** Test 10: OK
-*** Test 11:
-[{'group': 'MyGroup1', 'id': 3, 'priority': 10, 'pos1': [1, 5, 1], 'pos2': [1, 8, 3]}]
-OK
-[{'group': 'MyGroup1', 'id': 11, 'priority': 10, 'pos1': [1, 4, 2], 'pos2': [1, 9, 2]}]
-OK
diff --git a/src/nvim/testdir/test89.in b/src/nvim/testdir/test89.in
deleted file mode 100644
index f1f64fb41f..0000000000
--- a/src/nvim/testdir/test89.in
+++ /dev/null
@@ -1,71 +0,0 @@
-- Some tests for setting 'number' and 'relativenumber'
- This is not all that useful now that the options are no longer reset when
- setting the other.
-- Some tests for findfile() function
-
-STARTTEST
-:so small.vim
-:set hidden nu rnu
-:redir @a | set nu? rnu? | redir END
-:e! xx
-:redir @b | set nu? rnu? | redir END
-:e! #
-:$put ='results:'
-:$put a
-:$put b
-:"
-:set nonu nornu
-:setglobal nu
-:setlocal rnu
-:redir @c | setglobal nu? | redir END
-:set nonu nornu
-:setglobal rnu
-:setlocal nu
-:redir @d | setglobal rnu? | redir END
-:$put =':setlocal must NOT reset the other global value'
-:$put c
-:$put d
-:"
-:set nonu nornu
-:setglobal nu
-:setglobal rnu
-:redir @e | setglobal nu? | redir END
-:set nonu nornu
-:setglobal rnu
-:setglobal nu
-:redir @f | setglobal rnu? | redir END
-:$put =':setglobal MUST reset the other global value'
-:$put e
-:$put f
-:"
-:set nonu nornu
-:set nu
-:set rnu
-:redir @g | setglobal nu? | redir END
-:set nonu nornu
-:set rnu
-:set nu
-:redir @h | setglobal rnu? | redir END
-:$put =':set MUST reset the other global value'
-:$put g
-:$put h
-:"
-:let cwd=getcwd()
-:cd ..
-:" Tests may be run from a shadow directory, so an extra cd needs to be done to
-:" get above src/
-:if fnamemodify(getcwd(), ':t') != 'src' | cd ../.. | else | cd .. | endif
-:$put =''
-:$put ='Testing findfile'
-:$put =''
-:set ssl
-:$put =findfile('test19.in','src/nvim/test*')
-:exe "cd" cwd
-:cd ..
-:$put =findfile('test19.in','test*')
-:$put =findfile('test19.in','testdir')
-:exe "cd" cwd
-:/^results/,$w! test.out
-:q!
-ENDTEST
-
diff --git a/src/nvim/testdir/test89.ok b/src/nvim/testdir/test89.ok
deleted file mode 100644
index c8accd8569..0000000000
--- a/src/nvim/testdir/test89.ok
+++ /dev/null
@@ -1,28 +0,0 @@
-results:
-
- number
- relativenumber
-
- number
- relativenumber
-:setlocal must NOT reset the other global value
-
- number
-
- relativenumber
-:setglobal MUST reset the other global value
-
- number
-
- relativenumber
-:set MUST reset the other global value
-
- number
-
- relativenumber
-
-Testing findfile
-
-src/nvim/testdir/test19.in
-testdir/test19.in
-testdir/test19.in
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index b95a22d48b..4736e7a8ba 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -16,6 +16,11 @@
#include "nvim/os/event.h"
#include "nvim/tui/tui.h"
+// Space reserved in the output buffer to restore the cursor to normal when
+// flushing. No existing terminal will require 32 bytes to do that.
+#define CNORM_COMMAND_MAX_SIZE 32
+#define OUTBUF_SIZE 0xffff
+
typedef struct term_input TermInput;
#include "term_input.inl"
@@ -31,8 +36,8 @@ typedef struct {
typedef struct {
unibi_var_t params[9];
- char buf[0xffff];
- size_t bufpos;
+ char buf[OUTBUF_SIZE];
+ size_t bufpos, bufsize;
TermInput *input;
uv_loop_t *write_loop;
unibi_term *ut;
@@ -45,6 +50,7 @@ typedef struct {
int out_fd;
int old_height;
bool can_use_terminal_scroll;
+ bool busy;
HlAttrs attrs, print_attrs;
Cell **screen;
struct {
@@ -86,6 +92,7 @@ void tui_start(void)
data->fg = data->bg = -1;
data->can_use_terminal_scroll = true;
data->bufpos = 0;
+ data->bufsize = sizeof(data->buf) - CNORM_COMMAND_MAX_SIZE;
data->unibi_ext.enable_mouse = -1;
data->unibi_ext.disable_mouse = -1;
data->unibi_ext.enable_bracketed_paste = -1;
@@ -134,8 +141,8 @@ void tui_start(void)
ui->clear = tui_clear;
ui->eol_clear = tui_eol_clear;
ui->cursor_goto = tui_cursor_goto;
- ui->cursor_on = tui_cursor_on;
- ui->cursor_off = tui_cursor_off;
+ ui->busy_start = tui_busy_start;
+ ui->busy_stop = tui_busy_stop;
ui->mouse_on = tui_mouse_on;
ui->mouse_off = tui_mouse_off;
ui->insert_mode = tui_insert_mode;
@@ -169,6 +176,7 @@ static void tui_stop(UI *ui)
tui_normal_mode(ui);
tui_mouse_off(ui);
unibi_out(ui, unibi_exit_attribute_mode);
+ // cursor should be set to normal before exiting alternate screen
unibi_out(ui, unibi_cursor_normal);
unibi_out(ui, unibi_exit_ca_mode);
// Disable bracketed paste
@@ -342,14 +350,14 @@ static void tui_cursor_goto(UI *ui, int row, int col)
unibi_goto(ui, row, col);
}
-static void tui_cursor_on(UI *ui)
+static void tui_busy_start(UI *ui)
{
- unibi_out(ui, unibi_cursor_normal);
+ ((TUIData *)ui->data)->busy = true;
}
-static void tui_cursor_off(UI *ui)
+static void tui_busy_stop(UI *ui)
{
- unibi_out(ui, unibi_cursor_invisible);
+ ((TUIData *)ui->data)->busy = false;
}
static void tui_mouse_on(UI *ui)
@@ -527,6 +535,7 @@ static void tui_flush(UI *ui)
}
unibi_goto(ui, data->row, data->col);
+
flush_buf(ui);
}
@@ -657,7 +666,7 @@ static void out(void *ctx, const char *str, size_t len)
{
UI *ui = ctx;
TUIData *data = ui->data;
- size_t available = sizeof(data->buf) - data->bufpos;
+ size_t available = data->bufsize - data->bufpos;
if (len > available) {
flush_buf(ui);
@@ -781,14 +790,29 @@ end:
static void flush_buf(UI *ui)
{
- static uv_write_t req;
- static uv_buf_t buf;
+ uv_write_t req;
+ uv_buf_t buf;
TUIData *data = ui->data;
+
+ if (!data->busy) {
+ // not busy and the cursor is invisible(see below). Append a "cursor
+ // normal" command to the end of the buffer.
+ data->bufsize += CNORM_COMMAND_MAX_SIZE;
+ unibi_out(ui, unibi_cursor_normal);
+ data->bufsize -= CNORM_COMMAND_MAX_SIZE;
+ }
+
buf.base = data->buf;
buf.len = data->bufpos;
uv_write(&req, (uv_stream_t *)&data->output_handle, &buf, 1, NULL);
uv_run(data->write_loop, UV_RUN_DEFAULT);
data->bufpos = 0;
+
+ if (!data->busy) {
+ // not busy and cursor is visible(see above), append a "cursor invisible"
+ // command to the beginning of the buffer for the next flush
+ unibi_out(ui, unibi_cursor_invisible);
+ }
}
static void destroy_screen(TUIData *data)
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 62cc662b5b..443b50da87 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -44,7 +44,8 @@ static struct {
int top, bot, left, right;
} sr;
static int current_attr_code = 0;
-static bool cursor_enabled = true, pending_cursor_update = false;
+static bool pending_cursor_update = false;
+static int busy = 0;
static int height, width;
// This set of macros allow us to use UI_CALL to invoke any function on
@@ -150,21 +151,17 @@ void ui_resize(int new_width, int new_height)
UI_CALL(resize, width, height);
}
-void ui_cursor_on(void)
+void ui_busy_start(void)
{
- if (!cursor_enabled) {
- UI_CALL(cursor_on);
- cursor_enabled = true;
+ if (!(busy++)) {
+ UI_CALL(busy_start);
}
}
-void ui_cursor_off(void)
+void ui_busy_stop(void)
{
- if (full_screen) {
- if (cursor_enabled) {
- UI_CALL(cursor_off);
- }
- cursor_enabled = false;
+ if (!(--busy)) {
+ UI_CALL(busy_stop);
}
}
diff --git a/src/nvim/ui.h b/src/nvim/ui.h
index 4bc3983578..71ed9b3097 100644
--- a/src/nvim/ui.h
+++ b/src/nvim/ui.h
@@ -20,8 +20,8 @@ struct ui_t {
void (*clear)(UI *ui);
void (*eol_clear)(UI *ui);
void (*cursor_goto)(UI *ui, int row, int col);
- void (*cursor_on)(UI *ui);
- void (*cursor_off)(UI *ui);
+ void (*busy_start)(UI *ui);
+ void (*busy_stop)(UI *ui);
void (*mouse_on)(UI *ui);
void (*mouse_off)(UI *ui);
void (*insert_mode)(UI *ui);
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 2c287e0fdf..06dc325fea 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -99,7 +99,6 @@
#include "nvim/memline.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
-#include "nvim/misc2.h"
#include "nvim/memory.h"
#include "nvim/garray.h"
#include "nvim/option.h"
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 2c819c6f42..f876e78388 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -178,6 +178,48 @@ static char *(features[]) = {
// clang-format off
static int included_patches[] = {
+ //662,
+ //661,
+ 660,
+ //659,
+ //658,
+ //657,
+ //656,
+ //655,
+ //654,
+ //653,
+ //652,
+ //651,
+ //650,
+ //649,
+ //648,
+ //647,
+ //646,
+ //645,
+ //644,
+ //643,
+ //642,
+ //641,
+ //640,
+ //639,
+ //638,
+ 637,
+ //636,
+ //635,
+ //634,
+ //633,
+ //632,
+ //631,
+ //630,
+ //629,
+ //628,
+ //627,
+ //626,
+ //625,
+ //624,
+ //623,
+ //622,
+ //621,
//620,
//619,
//618,
diff --git a/src/nvim/vim.h b/src/nvim/vim.h
index 8f80efd88a..29d61dcbde 100644
--- a/src/nvim/vim.h
+++ b/src/nvim/vim.h
@@ -184,13 +184,6 @@ enum {
};
-#ifdef NO_EXPANDPATH
-# define gen_expand_wildcards mch_expand_wildcards
-#endif
-
-
-
-