aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/autoload/tutor.vim3
-rw-r--r--runtime/lua/man.lua6
-rw-r--r--src/nvim/api/buffer.c2
-rw-r--r--src/nvim/getchar.c23
-rw-r--r--src/nvim/misc1.c9
-rw-r--r--src/nvim/ops.c4
-rw-r--r--src/nvim/search.c8
-rw-r--r--src/nvim/spell.c25
-rw-r--r--src/nvim/testdir/Makefile1
-rw-r--r--src/nvim/testdir/test_cmdline.vim20
-rw-r--r--src/nvim/testdir/test_diffmode.vim20
-rw-r--r--src/nvim/testdir/test_search.vim7
-rw-r--r--src/nvim/testdir/test_spell.vim20
13 files changed, 112 insertions, 36 deletions
diff --git a/runtime/autoload/tutor.vim b/runtime/autoload/tutor.vim
index 56e2283465..0f01190b9b 100644
--- a/runtime/autoload/tutor.vim
+++ b/runtime/autoload/tutor.vim
@@ -2,9 +2,6 @@
" Setup: {{{1
function! tutor#SetupVim()
- if &columns < 90
- set columns=90
- endif
if !exists('g:did_load_ftplugin') || g:did_load_ftplugin != 1
filetype plugin on
endif
diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua
index baa522f343..b0fbe9cc35 100644
--- a/runtime/lua/man.lua
+++ b/runtime/lua/man.lua
@@ -148,8 +148,8 @@ local function highlight_line(line, linenr)
end
local function highlight_man_page()
- local mod = vim.api.nvim_eval("&modifiable")
- vim.api.nvim_command("set modifiable")
+ local mod = vim.api.nvim_buf_get_option(0, "modifiable")
+ vim.api.nvim_buf_set_option(0, "modifiable", true)
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
for i, line in ipairs(lines) do
@@ -162,7 +162,7 @@ local function highlight_man_page()
end
buf_hls = {}
- vim.api.nvim_command("let &modifiable = "..mod)
+ vim.api.nvim_buf_set_option(0, "modifiable", mod)
end
return { highlight_man_page = highlight_man_page }
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index fdde28f2bb..01dde9dd09 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -806,7 +806,7 @@ Integer nvim_buf_add_highlight(Buffer buffer,
/// Clears highlights from a given source group and a range of lines
///
-/// To clear a source group in the entire buffer, pass in 1 and -1 to
+/// To clear a source group in the entire buffer, pass in 0 and -1 to
/// line_start and line_end respectively.
///
/// @param buffer Buffer handle
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 1b5d3472ab..7df1bf8429 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -3366,6 +3366,10 @@ set_context_in_map_cmd (
arg = skipwhite(arg + 8);
continue;
}
+ if (STRNCMP(arg, "<special>", 9) == 0) {
+ arg = skipwhite(arg + 9);
+ continue;
+ }
if (STRNCMP(arg, "<script>", 8) == 0) {
arg = skipwhite(arg + 8);
continue;
@@ -3408,21 +3412,24 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
for (round = 1; round <= 2; ++round) {
count = 0;
- for (i = 0; i < 6; ++i) {
- if (i == 0)
+ for (i = 0; i < 7; i++) {
+ if (i == 0) {
p = (char_u *)"<silent>";
- else if (i == 1)
+ } else if (i == 1) {
p = (char_u *)"<unique>";
- else if (i == 2)
+ } else if (i == 2) {
p = (char_u *)"<script>";
- else if (i == 3)
+ } else if (i == 3) {
p = (char_u *)"<expr>";
- else if (i == 4 && !expand_buffer)
+ } else if (i == 4 && !expand_buffer) {
p = (char_u *)"<buffer>";
- else if (i == 5)
+ } else if (i == 5) {
p = (char_u *)"<nowait>";
- else
+ } else if (i == 6) {
+ p = (char_u *)"<special>";
+ } else {
continue;
+ }
if (vim_regexec(regmatch, p, (colnr_T)0)) {
if (round == 1)
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index f7ee2950ef..a498c7f4da 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -749,8 +749,9 @@ open_line (
// Postpone calling changed_lines(), because it would mess up folding
// with markers.
// Skip mark_adjust when adding a line after the last one, there can't
- // be marks there.
- if (curwin->w_cursor.lnum + 1 < curbuf->b_ml.ml_line_count) {
+ // be marks there. But still needed in diff mode.
+ if (curwin->w_cursor.lnum + 1 < curbuf->b_ml.ml_line_count
+ || curwin->w_p_diff) {
mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L, false);
}
did_append = true;
@@ -1864,8 +1865,8 @@ void appended_lines(linenr_T lnum, long count)
void appended_lines_mark(linenr_T lnum, long count)
{
// Skip mark_adjust when adding a line after the last one, there can't
- // be marks there.
- if (lnum + count < curbuf->b_ml.ml_line_count) {
+ // be marks there. But it's still needed in diff mode.
+ if (lnum + count < curbuf->b_ml.ml_line_count || curwin->w_p_diff) {
mark_adjust(lnum + 1, (linenr_T)MAXLNUM, count, 0L, false);
}
changed_lines(lnum + 1, 0, lnum + 1, count);
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index a5e131190d..295c985962 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -3177,9 +3177,9 @@ error:
curbuf->b_op_start.lnum++;
}
// Skip mark_adjust when adding lines after the last one, there
- // can't be marks there.
+ // can't be marks there. But still needed in diff mode.
if (curbuf->b_op_start.lnum + (y_type == kMTCharWise) - 1 + nr_lines
- < curbuf->b_ml.ml_line_count) {
+ < curbuf->b_ml.ml_line_count || curwin->w_p_diff) {
mark_adjust(curbuf->b_op_start.lnum + (y_type == kMTCharWise),
(linenr_T)MAXLNUM, nr_lines, 0L, false);
}
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 1eb1a25a19..0a266382ec 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -1382,13 +1382,13 @@ int searchc(cmdarg_T *cap, int t_cmd)
col -= (*mb_head_off)(p, p + col - 1) + 1;
}
if (lastc_bytelen == 1) {
- if (p[col] == c && stop)
+ if (p[col] == c && stop) {
break;
- } else {
- if (memcmp(p + col, lastc_bytes, lastc_bytelen) == 0 && stop)
+ }
+ } else if (STRNCMP(p + col, lastc_bytes, lastc_bytelen) == 0 && stop) {
break;
}
- stop = TRUE;
+ stop = true;
}
} else {
for (;; ) {
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index d2b2575f6a..b3e80bd768 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -1484,21 +1484,23 @@ spell_move_to (
return found_len;
}
- if (curline)
+ if (curline) {
break; // only check cursor line
+ }
+
+ // If we are back at the starting line and searched it again there
+ // is no match, give up.
+ if (lnum == wp->w_cursor.lnum && wrapped) {
+ break;
+ }
// Advance to next line.
if (dir == BACKWARD) {
- // If we are back at the starting line and searched it again there
- // is no match, give up.
- if (lnum == wp->w_cursor.lnum && wrapped)
- break;
-
- if (lnum > 1)
- --lnum;
- else if (!p_ws)
+ if (lnum > 1) {
+ lnum--;
+ } else if (!p_ws) {
break; // at first line and 'nowrapscan'
- else {
+ } else {
// Wrap around to the end of the buffer. May search the
// starting line again and accept the last match.
lnum = wp->w_buffer->b_ml.ml_line_count;
@@ -1523,8 +1525,9 @@ spell_move_to (
// If we are back at the starting line and there is no match then
// give up.
- if (lnum == wp->w_cursor.lnum && (!found_one || wrapped))
+ if (lnum == wp->w_cursor.lnum && !found_one) {
break;
+ }
// Skip the characters at the start of the next line that were
// included in a match crossing line boundaries.
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index 5af8dd20cd..a23dacba15 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -81,6 +81,7 @@ NEW_TESTS ?= \
test_search.res \
test_signs.res \
test_smartindent.res \
+ test_spell.res \
test_stat.res \
test_startup.res \
test_startup_utf8.res \
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index dc9790a39c..115c228ce8 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -25,6 +25,26 @@ func Test_complete_wildmenu()
set nowildmenu
endfunc
+func Test_map_completion()
+ if !has('cmdline_compl')
+ return
+ endif
+ call feedkeys(":map <unique> <si\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <unique> <silent>', getreg(':'))
+ call feedkeys(":map <script> <un\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <script> <unique>', getreg(':'))
+ call feedkeys(":map <expr> <sc\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <expr> <script>', getreg(':'))
+ call feedkeys(":map <buffer> <e\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <buffer> <expr>', getreg(':'))
+ call feedkeys(":map <nowait> <b\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <nowait> <buffer>', getreg(':'))
+ call feedkeys(":map <special> <no\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <special> <nowait>', getreg(':'))
+ call feedkeys(":map <silent> <sp\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <silent> <special>', getreg(':'))
+endfunc
+
func Test_expr_completion()
if !(has('cmdline_compl') && has('eval'))
return
diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim
index 8ee82bd538..88f73cdb5b 100644
--- a/src/nvim/testdir/test_diffmode.vim
+++ b/src/nvim/testdir/test_diffmode.vim
@@ -272,3 +272,23 @@ func Test_setting_cursor()
call delete('Xtest1')
call delete('Xtest2')
endfunc
+
+func Test_diff_lastline()
+ enew!
+ only!
+ call setline(1, ['This is a ', 'line with five ', 'rows'])
+ diffthis
+ botright vert new
+ call setline(1, ['This is', 'a line with ', 'four rows'])
+ diffthis
+ 1
+ call feedkeys("Je a\<CR>", 'tx')
+ call feedkeys("Je a\<CR>", 'tx')
+ let w1lines = winline()
+ wincmd w
+ $
+ let w2lines = winline()
+ call assert_equal(w2lines, w1lines)
+ bwipe!
+ bwipe!
+endfunc
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index a333e7f206..03112df46f 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -298,3 +298,10 @@ func Test_searchpair()
q!
endfunc
+func Test_searchc()
+ " These commands used to cause memory overflow in searchc().
+ new
+ norm ixx
+ exe "norm 0t\u93cf"
+ bw!
+endfunc
diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim
new file mode 100644
index 0000000000..334568aadb
--- /dev/null
+++ b/src/nvim/testdir/test_spell.vim
@@ -0,0 +1,20 @@
+" Test spell checking
+" TODO: move test58 tests here
+
+if v:true
+ finish
+endif
+
+func Test_wrap_search()
+ new
+ call setline(1, ['The', '', 'A plong line with two zpelling mistakes', '', 'End'])
+ set spell wrapscan
+ normal ]s
+ call assert_equal('plong', expand('<cword>'))
+ normal ]s
+ call assert_equal('zpelling', expand('<cword>'))
+ normal ]s
+ call assert_equal('plong', expand('<cword>'))
+ bwipe!
+ set nospell
+endfunc