aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorG-flat <63449095+G-flat@users.noreply.github.com>2020-10-05 15:15:10 +0800
committerGitHub <noreply@github.com>2020-10-05 15:15:10 +0800
commitb0769729c805ef33d47f383fd8b2ab18da5fa33c (patch)
treeee66236c5172c1b65b8a6415f756a78d6db29ac5 /src
parent1d08dfab5b057b51aed98450afd3ad1c888870ff (diff)
parentf7aeac7263c792e1503f9169abed20b6f5b9da99 (diff)
downloadrneovim-b0769729c805ef33d47f383fd8b2ab18da5fa33c.tar.gz
rneovim-b0769729c805ef33d47f383fd8b2ab18da5fa33c.tar.bz2
rneovim-b0769729c805ef33d47f383fd8b2ab18da5fa33c.zip
Merge pull request #1 from neovim/master
rebase
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/buffer.c6
-rw-r--r--src/nvim/ex_docmd.c34
-rw-r--r--src/nvim/extmark.c2
-rw-r--r--src/nvim/screen.c10
-rw-r--r--src/nvim/search.c27
-rw-r--r--src/nvim/testdir/test_cmdline.vim24
-rw-r--r--src/nvim/testdir/test_filetype.vim1
-rw-r--r--src/nvim/testdir/test_search.vim15
-rw-r--r--src/nvim/testdir/test_statusline.vim19
-rw-r--r--src/nvim/testdir/test_tagjump.vim34
-rw-r--r--src/nvim/undo.c3
-rw-r--r--src/nvim/window.c8
12 files changed, 156 insertions, 27 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index e77870dcf3..174f6e94a9 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -1420,7 +1420,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id,
}
id = extmark_set(buf, (uint64_t)ns_id, id,
- (int)line, (colnr_T)col, line2, col2, decor, kExtmarkUndo);
+ (int)line, (colnr_T)col, line2, col2, decor, kExtmarkNoUndo);
return (Integer)id;
@@ -1534,7 +1534,7 @@ Integer nvim_buf_add_highlight(Buffer buffer,
ns_id = extmark_set(buf, ns_id, 0,
(int)line, (colnr_T)col_start,
end_line, (colnr_T)col_end,
- decoration_hl(hl_id), kExtmarkUndo);
+ decoration_hl(hl_id), kExtmarkNoUndo);
return src_id;
}
@@ -1664,7 +1664,7 @@ Integer nvim_buf_set_virtual_text(Buffer buffer,
Decoration *decor = xcalloc(1, sizeof(*decor));
decor->virt_text = virt_text;
- extmark_set(buf, ns_id, 0, (int)line, 0, -1, -1, decor, kExtmarkUndo);
+ extmark_set(buf, ns_id, 0, (int)line, 0, -1, -1, decor, kExtmarkNoUndo);
return src_id;
}
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 7bb4bd32a3..ccaa0b0e52 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -258,6 +258,27 @@ void do_exmode(int improved)
msg_scroll = save_msg_scroll;
}
+// Print the executed command for when 'verbose' is set.
+// When "lnum" is 0 only print the command.
+static void msg_verbose_cmd(linenr_T lnum, char_u *cmd)
+ FUNC_ATTR_NONNULL_ALL
+{
+ no_wait_return++;
+ verbose_enter_scroll();
+
+ if (lnum == 0) {
+ smsg(_("Executing: %s"), cmd);
+ } else {
+ smsg(_("line %" PRIdLINENR ": %s"), lnum, cmd);
+ }
+ if (msg_silent == 0) {
+ msg_puts("\n"); // don't overwrite this
+ }
+
+ verbose_leave_scroll();
+ no_wait_return--;
+}
+
/*
* Execute a simple command line. Used for translated commands like "*".
*/
@@ -567,17 +588,8 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
}
}
- if (p_verbose >= 15 && sourcing_name != NULL) {
- ++no_wait_return;
- verbose_enter_scroll();
-
- smsg(_("line %" PRIdLINENR ": %s"), sourcing_lnum, cmdline_copy);
- if (msg_silent == 0) {
- msg_puts("\n"); // don't overwrite this either
- }
-
- verbose_leave_scroll();
- --no_wait_return;
+ if ((p_verbose >= 15 && sourcing_name != NULL) || p_verbose >= 16) {
+ msg_verbose_cmd(sourcing_lnum, cmdline_copy);
}
/*
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index 17141f12fd..0de396fd1f 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -783,7 +783,7 @@ void bufhl_add_hl_pos_offset(buf_T *buf,
}
(void)extmark_set(buf, (uint64_t)src_id, 0,
(int)lnum-1, hl_start, (int)lnum-1+end_off, hl_end,
- decor, kExtmarkUndo);
+ decor, kExtmarkNoUndo);
}
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index f3fdafcc70..3503348049 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -2822,6 +2822,16 @@ win_line (
n_extra = wp->w_p_rl ? (col + 1) : (grid->Columns - col);
}
+ if (draw_state == WL_LINE
+ && foldinfo.fi_level != 0
+ && foldinfo.fi_lines > 0
+ && col >= grid->Columns
+ && n_extra != 0
+ && row == startrow) {
+ // Truncate the folding.
+ n_extra = 0;
+ }
+
if (draw_state == WL_LINE && (area_highlighting || has_spell)) {
// handle Visual or match highlighting in this line
if (vcol == fromcol
diff --git a/src/nvim/search.c b/src/nvim/search.c
index b053459c7f..ea2107c5c7 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -651,6 +651,10 @@ int searchit(
colnr_T col = at_first_line && (options & SEARCH_COL) ? pos->col : 0;
nmatched = vim_regexec_multi(&regmatch, win, buf,
lnum, col, tm, timed_out);
+ // vim_regexec_multi() may clear "regprog"
+ if (regmatch.regprog == NULL) {
+ break;
+ }
// Abort searching on an error (e.g., out of stack).
if (called_emsg || (timed_out != NULL && *timed_out)) {
break;
@@ -722,6 +726,10 @@ int searchit(
match_ok = false;
break;
}
+ // vim_regexec_multi() may clear "regprog"
+ if (regmatch.regprog == NULL) {
+ break;
+ }
matchpos = regmatch.startpos[0];
endpos = regmatch.endpos[0];
submatch = first_submatch(&regmatch);
@@ -811,10 +819,13 @@ int searchit(
}
break;
}
-
- /* Need to get the line pointer again, a
- * multi-line search may have made it invalid. */
- ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
+ // vim_regexec_multi() may clear "regprog"
+ if (regmatch.regprog == NULL) {
+ break;
+ }
+ // Need to get the line pointer again, a
+ // multi-line search may have made it invalid.
+ ptr = ml_get_buf(buf, lnum + matchpos.lnum, false);
}
/*
@@ -891,6 +902,11 @@ int searchit(
}
at_first_line = FALSE;
+ // vim_regexec_multi() may clear "regprog"
+ if (regmatch.regprog == NULL) {
+ break;
+ }
+
// Stop the search if wrapscan isn't set, "stop_lnum" is
// specified, after an interrupt, after a match and after looping
// twice.
@@ -4243,7 +4259,8 @@ is_zero_width(char_u *pattern, int move, pos_T *cur, Direction direction)
if (nmatched != 0) {
break;
}
- } while (direction == FORWARD
+ } while (regmatch.regprog != NULL
+ && direction == FORWARD
? regmatch.startpos[0].col < pos.col
: regmatch.startpos[0].col > pos.col);
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index f8d84f1a49..871143699a 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -1,5 +1,8 @@
" Tests for editing the command line.
+source check.vim
+source screendump.vim
+
func Test_complete_tab()
call writefile(['testfile'], 'Xtestfile')
call feedkeys(":e Xtestf\t\r", "tx")
@@ -718,6 +721,27 @@ func Test_verbosefile()
call delete('Xlog')
endfunc
+func Test_verbose_option()
+ " See test/functional/ui/cmdline_spec.lua
+ CheckScreendump
+
+ let lines =<< trim [SCRIPT]
+ command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v
+ call feedkeys("\r", 't') " for the hit-enter prompt
+ set verbose=20
+ [SCRIPT]
+ call writefile(lines, 'XTest_verbose')
+
+ let buf = RunVimInTerminal('-S XTest_verbose', {'rows': 12})
+ call term_wait(buf, 100)
+ call term_sendkeys(buf, ":DoSomething\<CR>")
+ call VerifyScreenDump(buf, 'Test_verbose_option_1', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XTest_verbose')
+endfunc
+
func Test_setcmdpos()
func InsertTextAtPos(text, pos)
call assert_equal(0, setcmdpos(a:pos))
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index 9f8939f2f6..c7ca682c8c 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -128,6 +128,7 @@ let s:filename_checks = {
\ 'dart': ['file.dart', 'file.drt'],
\ 'datascript': ['file.ds'],
\ 'dcd': ['file.dcd'],
+ \ 'debchangelog': ['changelog.Debian', 'changelog.dch', 'NEWS.Debian', 'NEWS.dch', '/debian/changelog'],
\ 'debcontrol': ['/debian/control'],
\ 'debsources': ['/etc/apt/sources.list', '/etc/apt/sources.list.d/file.list'],
\ 'def': ['file.def'],
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index 211fc73562..5db23c22a8 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -981,6 +981,21 @@ func Test_incsearch_substitute()
call Incsearch_cleanup()
endfunc
+func Test_incsearch_substitute_long_line()
+ throw 'skipped: Nvim does not support test_override()'
+ new
+ call test_override("char_avail", 1)
+ set incsearch
+
+ call repeat('x', 100000)->setline(1)
+ call feedkeys(':s/\%c', 'xt')
+ redraw
+ call feedkeys("\<Esc>", 'xt')
+
+ call Incsearch_cleanup()
+ bwipe!
+endfunc
+
func Test_search_undefined_behaviour()
if !has("terminal")
return
diff --git a/src/nvim/testdir/test_statusline.vim b/src/nvim/testdir/test_statusline.vim
index 8c81ec3431..7efd181d04 100644
--- a/src/nvim/testdir/test_statusline.vim
+++ b/src/nvim/testdir/test_statusline.vim
@@ -412,3 +412,22 @@ func Test_statusline_removed_group()
call StopVimInTerminal(buf)
call delete('XTest_statusline')
endfunc
+
+func Test_statusline_after_split_vsplit()
+ only
+
+ " Make the status line of each window show the window number.
+ set ls=2 stl=%{winnr()}
+
+ split | redraw
+ vsplit | redraw
+
+ " The status line of the third window should read '3' here.
+ call assert_equal('3', nr2char(screenchar(&lines - 1, 1)))
+
+ only
+ set ls& stl&
+endfunc
+
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_tagjump.vim b/src/nvim/testdir/test_tagjump.vim
index 6abe5b7c89..7057cdefb2 100644
--- a/src/nvim/testdir/test_tagjump.vim
+++ b/src/nvim/testdir/test_tagjump.vim
@@ -1,5 +1,8 @@
" Tests for tagjump (tags and special searches)
+source check.vim
+source screendump.vim
+
" SEGV occurs in older versions. (At least 7.4.1748 or older)
func Test_ptag_with_notagstack()
set notagstack
@@ -551,6 +554,37 @@ func Test_tag_line_toolong()
let &verbose = old_vbs
endfunc
+" Check that using :tselect does not run into the hit-enter prompt.
+" Requires a terminal to trigger that prompt.
+func Test_tselect()
+ CheckScreendump
+
+ call writefile([
+ \ 'main Xtest.h /^void test();$/;" f',
+ \ 'main Xtest.c /^int main()$/;" f',
+ \ 'main Xtest.x /^void test()$/;" f',
+ \ ], 'Xtags')
+ cal writefile([
+ \ 'int main()',
+ \ 'void test()',
+ \ ], 'Xtest.c')
+
+ let lines =<< trim [SCRIPT]
+ set tags=Xtags
+ [SCRIPT]
+ call writefile(lines, 'XTest_tselect')
+ let buf = RunVimInTerminal('-S XTest_tselect', {'rows': 10, 'cols': 50})
+
+ call term_wait(buf, 100)
+ call term_sendkeys(buf, ":tselect main\<CR>2\<CR>")
+ call VerifyScreenDump(buf, 'Test_tselect_1', {})
+
+ call StopVimInTerminal(buf)
+ call delete('Xtags')
+ call delete('Xtest.c')
+ call delete('XTest_tselect')
+endfunc
+
func Test_tagline()
call writefile([
\ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:1 language:Python class:Foo',
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 97018f6c02..903e57732f 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -3029,8 +3029,6 @@ u_header_T *u_force_get_undo_header(buf_T *buf)
curbuf = buf;
// Args are tricky: this means replace empty range by empty range..
u_savecommon(0, 1, 1, true);
- curbuf = save_curbuf;
-
uhp = buf->b_u_curhead;
if (!uhp) {
uhp = buf->b_u_newhead;
@@ -3038,6 +3036,7 @@ u_header_T *u_force_get_undo_header(buf_T *buf)
abort();
}
}
+ curbuf = save_curbuf;
}
return uhp;
}
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 6608deb231..e53570edd8 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -1490,13 +1490,11 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
if (flags & (WSP_TOP | WSP_BOT))
(void)win_comp_pos();
- /*
- * Both windows need redrawing
- */
+ // Both windows need redrawing. Update all status lines, in case they
+ // show something related to the window count or position.
redraw_win_later(wp, NOT_VALID);
- wp->w_redr_status = TRUE;
redraw_win_later(oldwin, NOT_VALID);
- oldwin->w_redr_status = TRUE;
+ status_redraw_all();
if (need_status) {
msg_row = Rows - 1;