diff options
-rw-r--r-- | runtime/autoload/man.vim | 2 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 4 | ||||
-rw-r--r-- | src/nvim/mbyte.c | 13 | ||||
-rw-r--r-- | src/nvim/message.c | 7 | ||||
-rw-r--r-- | src/nvim/normal.c | 11 | ||||
-rw-r--r-- | src/nvim/regexp.c | 80 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 12 | ||||
-rw-r--r-- | src/nvim/screen.c | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test_alot.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_expr_utf8.vim | 57 | ||||
-rw-r--r-- | src/nvim/testdir/test_goto.vim | 12 | ||||
-rw-r--r-- | src/nvim/testdir/test_jumps.vim | 11 | ||||
-rw-r--r-- | src/nvim/version.c | 17 | ||||
-rw-r--r-- | test/functional/core/job_spec.lua | 4 | ||||
-rw-r--r-- | test/unit/helpers.lua | 1 | ||||
-rw-r--r-- | test/unit/preprocess.lua | 7 |
16 files changed, 185 insertions, 59 deletions
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index dbb46914a2..6fed4a54e3 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -106,7 +106,7 @@ function! s:system(cmd, ...) abort throw printf('command interrupted: %s', join(a:cmd)) endif if opts.exit_code != 0 - throw printf("command error (%d) %s: %s", jobid, join(a:cmd), opts.stderr) + throw printf("command error (%d) %s: %s", jobid, join(a:cmd), substitute(opts.stderr, '\_s\+$', '', &gdefault ? '' : 'g')) endif return opts.stdout diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 0a429a8d99..fcaf17a0fc 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2632,7 +2632,7 @@ void ex_append(exarg_T *eap) if (eap->cmdidx != CMD_append) --lnum; - /* when the buffer is empty append to line 0 and delete the dummy line */ + // when the buffer is empty need to delete the dummy line if (empty && lnum == 1) lnum = 0; @@ -2704,7 +2704,7 @@ void ex_append(exarg_T *eap) did_undo = TRUE; ml_append(lnum, theline, (colnr_T)0, FALSE); - appended_lines_mark(lnum, 1L); + appended_lines_mark(lnum + (empty ? 1 : 0), 1L); xfree(theline); ++lnum; diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 2ecd86974e..ec4969d4f6 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1315,6 +1315,10 @@ static int utf_convert(int a, const convertStruct *const table, size_t n_items) */ int utf_fold(int a) { + if (a < 0x80) { + // be fast for ASCII + return a >= 0x41 && a <= 0x5a ? a + 32 : a; + } return utf_convert(a, foldCase, ARRAY_SIZE(foldCase)); } @@ -2105,13 +2109,14 @@ char_u * enc_locale(void) } else s = p + 1; } - for (i = 0; s[i] != NUL && i < (int)sizeof(buf) - 1; ++i) { - if (s[i] == '_' || s[i] == '-') + for (i = 0; i < (int)sizeof(buf) - 1 && s[i] != NUL; i++) { + if (s[i] == '_' || s[i] == '-') { buf[i] = '-'; - else if (isalnum((int)s[i])) + } else if (isalnum((int)s[i])) { buf[i] = TOLOWER_ASC(s[i]); - else + } else { break; + } } buf[i] = NUL; diff --git a/src/nvim/message.c b/src/nvim/message.c index 3163a797ed..637b89ccbe 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2030,9 +2030,10 @@ static int do_more_prompt(int typed_char) int i; // We get called recursively when a timer callback outputs a message. In - // that case don't show another prompt. Also when at the hit-Enter prompt. - if (entered || State == HITRETURN) { - return false; + // that case don't show another prompt. Also when at the hit-Enter prompt + // and nothing was typed. + if (entered || (State == HITRETURN && typed_char == 0)) { + return false; } entered = true; diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 88ebdef9b3..227bfbe779 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3666,7 +3666,7 @@ find_decl ( size_t len, bool locally, bool thisblock, - int searchflags /* flags passed to searchit() */ + int flags_arg // flags passed to searchit() ) { char_u *pat; @@ -3678,6 +3678,7 @@ find_decl ( bool save_p_scs; bool retval = true; bool incll; + int searchflags = flags_arg; pat = xmalloc(len + 7); @@ -3751,10 +3752,12 @@ find_decl ( break; } - /* For finding a local variable and the match is before the "{" search - * to find a later match. For K&R style function declarations this - * skips the function header without types. */ + // For finding a local variable and the match is before the "{" search + // to find a later match. For K&R style function declarations this + // skips the function header without types. Remove SEARCH_START from + // flags to avoid getting stuck at one position. found_pos = curwin->w_cursor; + searchflags &= ~SEARCH_START; } if (t == false) { diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 64a70c295a..6613d284d7 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2309,48 +2309,64 @@ collection: } break; case CLASS_ALNUM: - for (cu = 1; cu <= 255; cu++) - if (isalnum(cu)) - regc(cu); + for (cu = 1; cu < 128; cu++) { + if (isalnum(cu)) { + regmbc(cu); + } + } break; case CLASS_ALPHA: - for (cu = 1; cu <= 255; cu++) - if (isalpha(cu)) - regc(cu); + for (cu = 1; cu < 128; cu++) { + if (isalpha(cu)) { + regmbc(cu); + } + } break; case CLASS_BLANK: regc(' '); regc('\t'); break; case CLASS_CNTRL: - for (cu = 1; cu <= 255; cu++) - if (iscntrl(cu)) - regc(cu); + for (cu = 1; cu <= 255; cu++) { + if (iscntrl(cu)) { + regmbc(cu); + } + } break; case CLASS_DIGIT: - for (cu = 1; cu <= 255; cu++) - if (ascii_isdigit(cu)) - regc(cu); + for (cu = 1; cu <= 255; cu++) { + if (ascii_isdigit(cu)) { + regmbc(cu); + } + } break; case CLASS_GRAPH: - for (cu = 1; cu <= 255; cu++) - if (isgraph(cu)) - regc(cu); + for (cu = 1; cu <= 255; cu++) { + if (isgraph(cu)) { + regmbc(cu); + } + } break; case CLASS_LOWER: - for (cu = 1; cu <= 255; cu++) - if (vim_islower(cu)) - regc(cu); + for (cu = 1; cu <= 255; cu++) { + if (vim_islower(cu) && cu != 170 && cu != 186) { + regmbc(cu); + } + } break; case CLASS_PRINT: - for (cu = 1; cu <= 255; cu++) - if (vim_isprintc(cu)) - regc(cu); + for (cu = 1; cu <= 255; cu++) { + if (vim_isprintc(cu)) { + regmbc(cu); + } + } break; case CLASS_PUNCT: - for (cu = 1; cu <= 255; cu++) - if (ispunct(cu)) - regc(cu); + for (cu = 1; cu < 128; cu++) { + if (ispunct(cu)) { + regmbc(cu); + } + } break; case CLASS_SPACE: for (cu = 9; cu <= 13; cu++) @@ -2358,14 +2374,18 @@ collection: regc(' '); break; case CLASS_UPPER: - for (cu = 1; cu <= 255; cu++) - if (vim_isupper(cu)) - regc(cu); + for (cu = 1; cu <= 255; cu++) { + if (vim_isupper(cu)) { + regmbc(cu); + } + } break; case CLASS_XDIGIT: - for (cu = 1; cu <= 255; cu++) - if (ascii_isxdigit(cu)) - regc(cu); + for (cu = 1; cu <= 255; cu++) { + if (ascii_isxdigit(cu)) { + regmbc(cu); + } + } break; case CLASS_TAB: regc('\t'); diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index d96858632f..474f3df32a 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -4320,12 +4320,14 @@ static int check_char_class(int class, int c) { switch (class) { case NFA_CLASS_ALNUM: - if (c >= 1 && c <= 255 && isalnum(c)) + if (c >= 1 && c < 128 && isalnum(c)) { return OK; + } break; case NFA_CLASS_ALPHA: - if (c >= 1 && c <= 255 && isalpha(c)) + if (c >= 1 && c < 128 && isalpha(c)) { return OK; + } break; case NFA_CLASS_BLANK: if (c == ' ' || c == '\t') @@ -4344,16 +4346,18 @@ static int check_char_class(int class, int c) return OK; break; case NFA_CLASS_LOWER: - if (vim_islower(c)) + if (vim_islower(c) && c != 170 && c != 186) { return OK; + } break; case NFA_CLASS_PRINT: if (vim_isprintc(c)) return OK; break; case NFA_CLASS_PUNCT: - if (c >= 1 && c <= 255 && ispunct(c)) + if (c >= 1 && c < 128 && ispunct(c)) { return OK; + } break; case NFA_CLASS_SPACE: if ((c >= 9 && c <= 13) || (c == ' ')) diff --git a/src/nvim/screen.c b/src/nvim/screen.c index b737c23851..41acc48f97 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -486,6 +486,11 @@ void update_single_line(win_T *wp, linenr_T lnum) int row; int j; + // Don't do anything if the screen structures are (not yet) valid. + if (!screen_valid(true)) { + return; + } + if (lnum >= wp->w_topline && lnum < wp->w_botline && foldedCount(wp, lnum, &win_foldinfo) == 0) { row = 0; diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index 5da122c45d..818ff7cf54 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -9,6 +9,7 @@ source test_expr.vim source test_expr_utf8.vim source test_feedkeys.vim source test_goto.vim +source test_jumps.vim source test_match.vim source test_matchadd_conceal_utf8.vim source test_menu.vim diff --git a/src/nvim/testdir/test_expr_utf8.vim b/src/nvim/testdir/test_expr_utf8.vim index 9ea6d8872b..097d708329 100644 --- a/src/nvim/testdir/test_expr_utf8.vim +++ b/src/nvim/testdir/test_expr_utf8.vim @@ -35,3 +35,60 @@ func Test_strcharpart_utf8() call assert_equal('̀', strcharpart('àxb', 1, 1)) call assert_equal('x', strcharpart('àxb', 2, 1)) endfunc + +func s:classes_test() + set isprint=@,161-255 + call assert_equal('Motörhead', matchstr('Motörhead', '[[:print:]]\+')) + + let alphachars = '' + let lowerchars = '' + let upperchars = '' + let alnumchars = '' + let printchars = '' + let punctchars = '' + let xdigitchars = '' + let i = 1 + while i <= 255 + let c = nr2char(i) + if c =~ '[[:alpha:]]' + let alphachars .= c + endif + if c =~ '[[:lower:]]' + let lowerchars .= c + endif + if c =~ '[[:upper:]]' + let upperchars .= c + endif + if c =~ '[[:alnum:]]' + let alnumchars .= c + endif + if c =~ '[[:print:]]' + let printchars .= c + endif + if c =~ '[[:punct:]]' + let punctchars .= c + endif + if c =~ '[[:xdigit:]]' + let xdigitchars .= c + endif + let i += 1 + endwhile + + call assert_equal('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', alphachars) + call assert_equal('abcdefghijklmnopqrstuvwxyzµßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ', lowerchars) + call assert_equal('ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ', upperchars) + call assert_equal('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', alnumchars) + call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ', printchars) + call assert_equal('!"#$%&''()*+,-./:;<=>?@[\]^_`{|}~', punctchars) + call assert_equal('0123456789ABCDEFabcdef', xdigitchars) +endfunc + +func Test_classes_re1() + set re=1 + call s:classes_test() +endfunc + +func Test_classes_re2() + set re=2 + call s:classes_test() +endfunc diff --git a/src/nvim/testdir/test_goto.vim b/src/nvim/testdir/test_goto.vim index fb8f190fa6..2afd96b296 100644 --- a/src/nvim/testdir/test_goto.vim +++ b/src/nvim/testdir/test_goto.vim @@ -1,6 +1,6 @@ " Test commands that jump somewhere. -func Test_geedee() +func Test_geeDEE() new call setline(1, ["Filename x;", "", "int Filename", "int func() {", "Filename y;"]) /y;/ @@ -8,3 +8,13 @@ func Test_geedee() call assert_equal(1, line('.')) quit! endfunc + +func Test_gee_dee() + new + call setline(1, ["int x;", "", "int func(int x)", "{", " return x;", "}"]) + /return/ + normal $hgd + call assert_equal(3, line('.')) + call assert_equal(14, col('.')) + quit! +endfunc diff --git a/src/nvim/testdir/test_jumps.vim b/src/nvim/testdir/test_jumps.vim new file mode 100644 index 0000000000..5a3717d165 --- /dev/null +++ b/src/nvim/testdir/test_jumps.vim @@ -0,0 +1,11 @@ +func Test_empty_buffer() + new + insert +a +b +c +d +. + call assert_equal(1, line("''")) + bwipe! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index d06741f1b6..9f2b7a26c3 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -412,7 +412,7 @@ static int included_patches[] = { // 2031, // 2030 NA // 2029, - // 2028, + 2028, // 2027 NA // 2026 NA // 2025 NA @@ -421,7 +421,7 @@ static int included_patches[] = { // 2022, // 2021, // 2020 NA - // 2019, + 2019, // 2018, // 2017, // 2016 NA @@ -470,7 +470,7 @@ static int included_patches[] = { 1973, // 1972, 1971, - // 1970, + 1970, // 1969 NA // 1968, 1967, @@ -500,7 +500,7 @@ static int included_patches[] = { // 1943 NA // 1942 NA 1941, - // 1940, + 1940, // 1939 NA // 1938 NA 1937, @@ -564,7 +564,7 @@ static int included_patches[] = { // 1879 NA // 1878 NA // 1877 NA - // 1876, + 1876, 1875, // 1874 NA // 1873 NA @@ -606,6 +606,7 @@ static int included_patches[] = { 1837, 1836, 1835, + 1834, 1833, 1832, 1831, @@ -646,7 +647,7 @@ static int included_patches[] = { // 1796 NA // 1795 NA // 1794 NA - // 1793, + 1793, // 1792 NA // 1791 NA // 1790 NA @@ -655,9 +656,9 @@ static int included_patches[] = { // 1788 NA // 1787 NA // 1786 NA - // 1785, + 1785, // 1784 NA - // 1783, + 1783, 1782, // 1781, 1780, diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index e4b6621ff9..75b50aad0a 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -508,7 +508,9 @@ describe('jobs', function() it('jobclose() sends SIGHUP', function() nvim('command', 'call jobclose(j)') - eq({'notification', 'exit', {0, 42}}, next_msg()) + local msg = next_msg() + msg = (msg[2] == 'stdout') and next_msg() or msg -- Skip stdout, if any. + eq({'notification', 'exit', {0, 42}}, msg) end) end) end) diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua index 91da459393..3564f76442 100644 --- a/test/unit/helpers.lua +++ b/test/unit/helpers.lua @@ -36,6 +36,7 @@ local function filter_complex_blocks(body) or string.find(line, "_ISwupper", 1, true) or string.find(line, "msgpack_zone_push_finalizer") or string.find(line, "msgpack_unpacker_reserve_buffer") + or string.find(line, "UUID_NULL") -- static const uuid_t UUID_NULL = {...} or string.find(line, "inline _Bool")) then result[#result + 1] = line end diff --git a/test/unit/preprocess.lua b/test/unit/preprocess.lua index e5c838b13b..10ba997758 100644 --- a/test/unit/preprocess.lua +++ b/test/unit/preprocess.lua @@ -105,7 +105,12 @@ local Gcc = { '-DINCLUDE_GENERATED_DECLARATIONS', -- Needed for FreeBSD - '-D "_Thread_local="' + '-D "_Thread_local="', + + -- Needed for macOS Sierra + '-D "_Nullable="', + '-D "_Nonnull="', + '-U__BLOCKS__', } } |