aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/README.md6
-rw-r--r--src/nvim/buffer.c2
-rw-r--r--src/nvim/diff.c6
-rw-r--r--src/nvim/main.c3
-rw-r--r--src/nvim/misc1.c11
-rw-r--r--src/nvim/normal.c4
-rw-r--r--src/nvim/options.lua2
-rw-r--r--src/nvim/os/shell.c38
-rw-r--r--src/nvim/os/time.c22
-rw-r--r--src/nvim/os_unix.c3
-rw-r--r--src/nvim/search.c17
-rw-r--r--src/nvim/terminal.c3
-rw-r--r--src/nvim/testdir/runtest.vim11
-rw-r--r--src/nvim/testdir/setup.vim12
-rw-r--r--src/nvim/ui.c7
-rw-r--r--src/nvim/version.c26
16 files changed, 105 insertions, 68 deletions
diff --git a/src/nvim/README.md b/src/nvim/README.md
index 1ece92e44d..d668db0cdc 100644
--- a/src/nvim/README.md
+++ b/src/nvim/README.md
@@ -90,6 +90,12 @@ Record a Nvim terminal session and format it with `vterm-dump`:
Then you can compare `bar` with another session, to debug TUI behavior.
+### TUI redraw
+
+Set the 'writedelay' option to see where and when the UI is painted.
+
+ :set writedelay=1
+
### Terminal reference
- `man terminfo`
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index e5da5b835b..a86a908492 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -4466,7 +4466,7 @@ do_arg_all (
// leaving an empty tab page when executed locally.
if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1
&& curbuf->b_ffname == NULL && !curbuf->b_changed) {
- use_firstwin = TRUE;
+ use_firstwin = true;
}
for (i = 0; i < count && i < opened_len && !got_int; ++i) {
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index c2ab57a59b..e55cf7bf7e 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -855,7 +855,7 @@ void ex_diffpatch(exarg_T *eap)
{
char_u *buf = NULL;
win_T *old_curwin = curwin;
- char_u *newname = NULL; // name of patched file buffer
+ char_u *newname = NULL; // name of patched file buffer
char_u *esc_name = NULL;
#ifdef UNIX
@@ -886,9 +886,9 @@ void ex_diffpatch(exarg_T *eap)
esc_name = vim_strsave_shellescape(
#ifdef UNIX
- fullname != NULL ? fullname :
+ fullname != NULL ? fullname :
#endif
- eap->arg, true, true);
+ eap->arg, true, true);
if (esc_name == NULL) {
goto theend;
}
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 3402e2bebc..4fd55f1491 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -577,8 +577,9 @@ int main(int argc, char **argv)
return 0;
}
-/* Exit properly */
+/// Exit properly
void getout(int exitval)
+ FUNC_ATTR_NORETURN
{
tabpage_T *tp, *next_tp;
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index a498c7f4da..8bd59b5886 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -2610,13 +2610,12 @@ int match_user(char_u *name)
return result;
}
-/*
- * Preserve files and exit.
- * When called IObuff must contain a message.
- * NOTE: This may be called from deathtrap() in a signal handler, avoid unsafe
- * functions, such as allocating memory.
- */
+/// Preserve files and exit.
+/// @note IObuff must contain a message.
+/// @note This may be called from deadly_signal() in a signal handler, avoid
+/// unsafe functions, such as allocating memory.
void preserve_exit(void)
+ FUNC_ATTR_NORETURN
{
// 'true' when we are sure to exit, e.g., after a deadly signal
static bool really_exiting = false;
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 47044a6072..bca4a0f93e 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -5031,8 +5031,8 @@ static void nv_right(cmdarg_T *cap)
if ((!PAST_LINE && oneright() == false)
|| (PAST_LINE && *get_cursor_pos_ptr() == NUL)
) {
- // <Space> wraps to next line if 'whichwrap' has 's'.
- // 'l' wraps to next line if 'whichwrap' has 'l'.
+ // <Space> wraps to next line if 'whichwrap' has 's'.
+ // 'l' wraps to next line if 'whichwrap' has 'l'.
// CURS_RIGHT wraps to next line if 'whichwrap' has '>'.
if (((cap->cmdchar == ' ' && vim_strchr(p_ww, 's') != NULL)
|| (cap->cmdchar == 'l' && vim_strchr(p_ww, 'l') != NULL)
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index db7ed9da45..dac5c0ee16 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -2185,7 +2185,7 @@ return {
type='number', scope={'global'},
vi_def=true,
varname='p_ss',
- defaults={if_true={vi=0}}
+ defaults={if_true={vi=1}}
},
{
full_name='sidescrolloff', abbreviation='siso',
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index 11e6a76939..f650a51fe7 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -422,7 +422,7 @@ static void out_data_ring(char *output, size_t size)
}
if (output == NULL && size == SIZE_MAX) { // Print mode
- out_data_append_to_screen(last_skipped, last_skipped_len, true);
+ out_data_append_to_screen(last_skipped, &last_skipped_len, true);
return;
}
@@ -450,30 +450,40 @@ static void out_data_ring(char *output, size_t size)
/// @param output Data to append to screen lines.
/// @param remaining Size of data.
/// @param new_line If true, next data output will be on a new line.
-static void out_data_append_to_screen(char *output, size_t remaining,
- bool new_line)
+static void out_data_append_to_screen(char *output, size_t *count,
+ bool eof)
{
- char *p = output, *end = output + remaining;
+ char *p = output, *end = output + *count;
while (p < end) {
- if (*p == '\n' || *p == '\r' || *p == TAB) {
+ if (*p == '\n' || *p == '\r' || *p == TAB || *p == BELL) {
msg_putchar_attr((uint8_t)(*p), 0);
p++;
} else {
+ // Note: this is not 100% precise:
+ // 1. we don't check if received continuation bytes are already invalid
+ // and we thus do some buffering that could be avoided
+ // 2. we don't compose chars over buffer boundaries, even if we see an
+ // incomplete UTF-8 sequence that could be composing with the last
+ // complete sequence.
+ // This will be corrected when we switch to vterm based implementation
int i = *p ? mb_ptr2len_len((char_u *)p, (int)(end-p)) : 1;
+ if (!eof && i == 1 && utf8len_tab_zero[*(uint8_t *)p] > (end-p)) {
+ *count = (size_t)(p - output);
+ goto end;
+ }
(void)msg_outtrans_len_attr((char_u *)p, i, 0);
p += i;
}
}
+end:
ui_flush();
}
static void out_data_cb(Stream *stream, RBuffer *buf, size_t count, void *data,
bool eof)
{
- // We always output the whole buffer, so the buffer can never
- // wrap around.
size_t cnt;
char *ptr = rbuffer_read_ptr(buf, &cnt);
@@ -482,12 +492,16 @@ static void out_data_cb(Stream *stream, RBuffer *buf, size_t count, void *data,
// Save the skipped output. If it is the final chunk, we display it later.
out_data_ring(ptr, cnt);
} else {
- out_data_append_to_screen(ptr, cnt, eof);
+ out_data_append_to_screen(ptr, &cnt, eof);
}
if (cnt) {
rbuffer_consumed(buf, cnt);
}
+
+ // Move remaining data to start of buffer, so the buffer can never
+ // wrap around.
+ rbuffer_reset(buf);
}
/// Parses a command string into a sequence of words, taking quotes into
@@ -576,14 +590,10 @@ static void read_input(DynamicBuffer *buf)
if (len == l) {
// Finished a line, add a NL, unless this line should not have one.
- // FIXME need to make this more readable
if (lnum != curbuf->b_op_end.lnum
- || (!curbuf->b_p_bin
- && curbuf->b_p_fixeol)
+ || (!curbuf->b_p_bin && curbuf->b_p_fixeol)
|| (lnum != curbuf->b_no_eol_lnum
- && (lnum !=
- curbuf->b_ml.ml_line_count
- || curbuf->b_p_eol))) {
+ && (lnum != curbuf->b_ml.ml_line_count || curbuf->b_p_eol))) {
dynamic_buffer_ensure(buf, buf->len + 1);
buf->data[buf->len++] = NL;
}
diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c
index c471352c02..290d421acc 100644
--- a/src/nvim/os/time.c
+++ b/src/nvim/os/time.c
@@ -38,33 +38,33 @@ uint64_t os_hrtime(void)
return uv_hrtime();
}
-/// Sleeps for a certain amount of milliseconds.
+/// Sleeps for `ms` milliseconds.
///
-/// @param milliseconds Number of milliseconds to sleep
+/// @param ms Number of milliseconds to sleep
/// @param ignoreinput If true, only SIGINT (CTRL-C) can interrupt.
-void os_delay(uint64_t milliseconds, bool ignoreinput)
+void os_delay(uint64_t ms, bool ignoreinput)
{
if (ignoreinput) {
- if (milliseconds > INT_MAX) {
- milliseconds = INT_MAX;
+ if (ms > INT_MAX) {
+ ms = INT_MAX;
}
- LOOP_PROCESS_EVENTS_UNTIL(&main_loop, NULL, (int)milliseconds, got_int);
+ LOOP_PROCESS_EVENTS_UNTIL(&main_loop, NULL, (int)ms, got_int);
} else {
- os_microdelay(milliseconds * 1000u, ignoreinput);
+ os_microdelay(ms * 1000u, ignoreinput);
}
}
-/// Sleeps for a certain amount of microseconds.
+/// Sleeps for `us` microseconds.
///
-/// @param ms Number of microseconds to sleep.
+/// @param us Number of microseconds to sleep.
/// @param ignoreinput If true, ignore all input (including SIGINT/CTRL-C).
/// If false, waiting is aborted on any input.
-void os_microdelay(uint64_t ms, bool ignoreinput)
+void os_microdelay(uint64_t us, bool ignoreinput)
{
uint64_t elapsed = 0u;
uint64_t base = uv_hrtime();
// Convert microseconds to nanoseconds, or UINT64_MAX on overflow.
- const uint64_t ns = (ms < UINT64_MAX / 1000u) ? ms * 1000u : UINT64_MAX;
+ const uint64_t ns = (us < UINT64_MAX / 1000u) ? us * 1000u : UINT64_MAX;
uv_mutex_lock(&delay_mutex);
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index d7ba675b68..a27fee4e90 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -133,7 +133,8 @@ void mch_free_acl(vim_acl_T aclent)
}
#endif
-void mch_exit(int r) FUNC_ATTR_NORETURN
+void mch_exit(int r)
+ FUNC_ATTR_NORETURN
{
exiting = true;
diff --git a/src/nvim/search.c b/src/nvim/search.c
index bbcac45369..533a28de35 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -775,12 +775,17 @@ int searchit(
}
}
if (ptr[matchcol] == NUL
- || (nmatched = vim_regexec_multi(&regmatch,
- win, buf, lnum + matchpos.lnum,
- matchcol,
- tm
- )) == 0)
- break;
+ || (nmatched = vim_regexec_multi(
+ &regmatch, win, buf, lnum + matchpos.lnum, matchcol,
+ tm)) == 0) {
+ // If the search timed out, we did find a match
+ // but it might be the wrong one, so that's not
+ // OK.
+ if (tm != NULL && profile_passed_limit(*tm)) {
+ match_ok = false;
+ }
+ break;
+ }
/* Need to get the line pointer again, a
* multi-line search may have made it invalid. */
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index dfa758f41e..137855469f 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -61,7 +61,6 @@
#include "nvim/edit.h"
#include "nvim/mouse.h"
#include "nvim/memline.h"
-#include "nvim/mark.h"
#include "nvim/map.h"
#include "nvim/misc1.h"
#include "nvim/move.h"
@@ -376,8 +375,6 @@ void terminal_enter(void)
// Ensure the terminal is properly sized.
terminal_resize(s->term, 0, 0);
- checkpcmark();
- setpcmark();
int save_state = State;
s->save_rd = RedrawingDisabled;
State = TERM_FOCUS;
diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim
index 4de1345679..01ba8baf02 100644
--- a/src/nvim/testdir/runtest.vim
+++ b/src/nvim/testdir/runtest.vim
@@ -62,20 +62,9 @@ lang mess C
" Always use forward slashes.
set shellslash
-" Make sure $HOME does not get read or written.
-let $HOME = '/does/not/exist'
-
" Prepare for calling garbagecollect_for_testing().
let v:testing = 1
-" Align Nvim defaults to Vim.
-set directory^=.
-set backspace=
-set nohidden smarttab noautoindent noautoread complete-=i noruler noshowcmd
-set listchars=eol:$
-" Prevent Nvim log from writing to stderr.
-let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log'
-
func RunTheTest(test)
echo 'Executing ' . a:test
if exists("*SetUp")
diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim
index 06f2199214..87cf1f6163 100644
--- a/src/nvim/testdir/setup.vim
+++ b/src/nvim/testdir/setup.vim
@@ -1,8 +1,14 @@
" Common preparations for running tests.
-set noruler
-set noshowcmd
-set belloff=
+" Align Nvim defaults to Vim.
+set sidescroll=0
+set directory^=.
+set backspace=
+set nohidden smarttab noautoindent noautoread complete-=i noruler noshowcmd
+set listchars=eol:$
+" Prevent Nvim log from writing to stderr.
+let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log'
+
" Make sure 'runtimepath' and 'packpath' does not include $HOME.
set rtp=$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 8aec923538..709a172449 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -453,6 +453,13 @@ void ui_puts(uint8_t *str)
ui_linefeed();
}
p += clen;
+
+ if (p_wd) { // 'writedelay': flush & delay each time.
+ ui_flush();
+ assert(p_wd >= 0
+ && (sizeof(long) <= sizeof(uint64_t) || p_wd <= UINT64_MAX));
+ os_delay((uint64_t)p_wd, false);
+ }
}
}
diff --git a/src/nvim/version.c b/src/nvim/version.c
index c95be072cf..5fd94fcee8 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -78,6 +78,22 @@ NULL
// clang-format off
static const int included_patches[] = {
+ 1435,
+ // 1434,
+ // 1433,
+ // 1432,
+ // 1431,
+ // 1430,
+ // 1429,
+ // 1428,
+ // 1427,
+ // 1426,
+ // 1425,
+ // 1424,
+ // 1423,
+ // 1422,
+ // 1421,
+ // 1420,
1419,
// 1418,
// 1417,
@@ -1039,7 +1055,7 @@ static const int included_patches[] = {
461,
// 460,
459,
- // 458,
+ 458,
457,
// 456,
// 455,
@@ -1063,7 +1079,7 @@ static const int included_patches[] = {
437,
// 436,
// 435,
- // 434,
+ 434,
433,
// 432,
431,
@@ -1073,7 +1089,7 @@ static const int included_patches[] = {
427,
426,
// 425,
- // 424,
+ 424,
423,
// 422,
421,
@@ -1312,7 +1328,7 @@ static const int included_patches[] = {
188,
187,
186,
- // 185,
+ 185,
// 184,
183,
182,
@@ -1322,7 +1338,7 @@ static const int included_patches[] = {
178,
177,
176,
- // 175,
+ 175,
174,
173,
172,