Compare commits

...

10 Commits

Author SHA1 Message Date
Bram Moolenaar
6f9a476b2f patch 8.0.0656: cannot use ! after some user commands
Problem:    Cannot use ! after some user commands.
Solution:   Properly check for existing command. (Higashi Higashi)
2017-06-22 20:39:17 +02:00
Bram Moolenaar
d6abcd154c patch 8.0.0655: not easy to make sure a function does not exist
Problem:    Not easy to make sure a function does not exist.
Solution:   Add ! as an optional argument to :delfunc.
2017-06-22 19:15:24 +02:00
Bram Moolenaar
663bb23316 patch 8.0.0654: no warning for text after :endfunction
Problem:    Text found after :endfunction is silently ignored.
Solution:   Give a warning if 'verbose' is set.  When | or \n are used,
            execute the text as a command.
2017-06-22 19:12:10 +02:00
Bram Moolenaar
c768a208ca patch 8.0.0653: the default highlight for QuickFixLine is not good
Problem:    The default highlight for QuickFixLine does not work for several
            color schemes. (Manas Thakur)
Solution:   Make the default use the old color. (closes #1780)
2017-06-22 16:04:27 +02:00
Bram Moolenaar
383aa84c0d patch 8.0.0652: unicode information is outdated
Problem:    Unicode information is outdated.
Solution:   Update to Unicode 10. (Christian Brabandt)
2017-06-22 15:27:37 +02:00
Bram Moolenaar
157069b04e patch 8.0.0651: build failure without the auto command feature
Problem:    Build failure without the auto command feature.
Solution:   Add #ifdef. (closes #1782)
2017-06-22 14:56:12 +02:00
Bram Moolenaar
868831f122 patch 8.0.0650: for extra help files the filetype is set more than once
Problem:    For extra help files the filetype is set more than once.
Solution:   In *.txt files check that there is no help file modline.
2017-06-22 14:47:22 +02:00
Bram Moolenaar
9049298f8d patch 8.0.0649: when opening a help file the filetype is set several times
Problem:    When opening a help file the filetype is set several times.
Solution:   When setting the filetype to the same value from a modeline, don't
            trigger FileType autocommands.  Don't set the filetype to "help"
            when it's already set correctly.
2017-06-22 14:16:31 +02:00
Bram Moolenaar
fadacf01d0 patch 8.0.0648: possible use of NULL pointer
Problem:    Possible use of NULL pointer if buflist_new() returns NULL.
            (Coverity)
Solution:   Check for NULL pointer in set_bufref().
2017-06-19 20:35:32 +02:00
Bram Moolenaar
06f1ed2f78 patch 8.0.0647: syntax highlighting can make cause a freeze
Problem:    Syntax highlighting can make cause a freeze.
Solution:   Apply 'redrawtime' to syntax highlighting, per window.
2017-06-18 22:41:03 +02:00
20 changed files with 391 additions and 100 deletions

View File

@@ -1,4 +1,4 @@
*eval.txt* For Vim version 8.0. Last change: 2017 Jun 13
*eval.txt* For Vim version 8.0. Last change: 2017 Jun 22
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -8764,18 +8764,32 @@ See |:verbose-cmd| for more information.
implies that the effect of |:nohlsearch| is undone
when the function returns.
*:endf* *:endfunction* *E126* *E193*
:endf[unction] The end of a function definition. Must be on a line
by its own, without other commands.
*:endf* *:endfunction* *E126* *E193* *E946*
:endf[unction] [argument]
The end of a function definition. Best is to put it
on a line by its own, without [argument].
[argument] can be:
| command command to execute next
\n command command to execute next
" comment always ignored
anything else ignored, unless 'verbose' is
non-zero
The support for a following command was added in Vim
8.0.0654, before that any argument was silently
ignored.
*:delf* *:delfunction* *E130* *E131* *E933*
:delf[unction] {name} Delete function {name}.
:delf[unction][!] {name}
Delete function {name}.
{name} can also be a |Dictionary| entry that is a
|Funcref|: >
:delfunc dict.init
< This will remove the "init" entry from "dict". The
function is deleted if there are no more references to
it.
With the ! there is no error if the function does not
exist.
*:retu* *:return* *E133*
:retu[rn] [expr] Return from a function. When "[expr]" is given, it is
evaluated and returned as the result of the function.

View File

@@ -1,4 +1,4 @@
*options.txt* For Vim version 8.0. Last change: 2017 Jun 13
*options.txt* For Vim version 8.0. Last change: 2017 Jun 18
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -5945,10 +5945,14 @@ A jump table for the options with a short description can be found at |Q_op|.
{only available when compiled with the |+reltime|
feature}
The time in milliseconds for redrawing the display. This applies to
searching for patterns for 'hlsearch' and |:match| highlighting.
searching for patterns for 'hlsearch', |:match| highlighting an syntax
highlighting.
When redrawing takes more than this many milliseconds no further
matches will be highlighted. This is used to avoid that Vim hangs
when using a very complicated pattern.
matches will be highlighted.
For syntax highlighting the time applies per window. When over the
limit syntax highlighting is disabled until |CTRL-L| is used.
This is used to avoid that Vim hangs when using a very complicated
pattern.
*'regexpengine'* *'re'*
'regexpengine' 're' number (default 0)

View File

@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2017 Jun 12
" Last Change: 2017 Jun 22
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
@@ -48,6 +48,9 @@ func! s:StarSetf(ft)
endif
endfunc
" Vim help file
au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help
" Abaqus or Trasys
au BufNewFile,BufRead *.inp call s:Check_inp()
@@ -2786,7 +2789,13 @@ au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh')
" Plain text files, needs to be far down to not override others. This avoids
" the "conf" type being used if there is a line starting with '#'.
au BufNewFile,BufRead *.txt,*.text,README setf text
au BufNewFile,BufRead *.text,README setf text
" Help files match *.txt but should have a last line that is a modeline.
au BufNewFile,BufRead *.txt
\ if getline('$') !~ 'vim:.*ft=help'
\| setf text
\| endif
" Use the filetype detect plugins. They may overrule any of the previously

View File

@@ -3,6 +3,7 @@
" http://www.unicode.org/Public/5.1.0/ucd/UCD.html
" For the other files see the header.
"
" Might need to update the URL to the emoji-data.txt
" Usage: Vim -S <this-file>
"
" Author: Bram Moolenaar
@@ -382,8 +383,9 @@ let s:ambitable = []
call BuildWidthTable('A', 'ambiguous')
" Edit the emoji text file. Requires the netrw plugin.
edit http://www.unicode.org/Public/emoji/3.0/emoji-data.txt
edit http://unicode.org/Public/emoji/5.0/emoji-data.txt
"edit http://www.unicode.org/Public/emoji/latest/emoji-data.txt
" Build the emoji table. Ver. 1.0 - 6.0
" Must come after the "ambiguous" table
call BuildEmojiTable('; Emoji\s\+# [1-6]\.[0-9]', 'emoji')
call BuildEmojiTable('; Emoji\s\+#\s\+\d\+\.\d', 'emoji')

View File

@@ -372,7 +372,7 @@ open_buffer(
set_bufref(bufref_T *bufref, buf_T *buf)
{
bufref->br_buf = buf;
bufref->br_fnum = buf->b_fnum;
bufref->br_fnum = buf == NULL ? 0 : buf->b_fnum;
bufref->br_buf_free_count = buf_free_count;
}

View File

@@ -6832,8 +6832,11 @@ fix_help_buffer(void)
char_u *rt;
int mustfree;
/* set filetype to "help". */
set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL);
#ifdef FEAT_AUTOCMD
/* Set filetype to "help" if still needed. */
if (STRCMP(curbuf->b_p_ft, "help") != 0)
set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL);
#endif
#ifdef FEAT_SYN_HL
if (!syntax_present(curwin))

View File

@@ -426,7 +426,7 @@ EX(CMD_delcommand, "delcommand", ex_delcommand,
NEEDARG|WORD1|TRLBAR|CMDWIN,
ADDR_LINES),
EX(CMD_delfunction, "delfunction", ex_delfunction,
NEEDARG|WORD1|CMDWIN,
BANG|NEEDARG|WORD1|CMDWIN,
ADDR_LINES),
EX(CMD_display, "display", ex_display,
EXTRA|NOTRLCOM|TRLBAR|SBOXOK|CMDWIN,

View File

@@ -2370,7 +2370,8 @@ do_one_cmd(
goto doend;
}
/* Check for wrong commands. */
if (*p == '!' && ea.cmd[1] == 0151 && ea.cmd[0] == 78)
if (*p == '!' && ea.cmd[1] == 0151 && ea.cmd[0] == 78
&& !IS_USER_CMDIDX(ea.cmdidx))
{
errormsg = uc_fun_cmd();
goto doend;

View File

@@ -1451,7 +1451,7 @@ utf_char2cells(int c)
{0x3000, 0x303e},
{0x3041, 0x3096},
{0x3099, 0x30ff},
{0x3105, 0x312d},
{0x3105, 0x312e},
{0x3131, 0x318e},
{0x3190, 0x31ba},
{0x31c0, 0x31e3},
@@ -1470,10 +1470,11 @@ utf_char2cells(int c)
{0xfe68, 0xfe6b},
{0xff01, 0xff60},
{0xffe0, 0xffe6},
{0x16fe0, 0x16fe0},
{0x16fe0, 0x16fe1},
{0x17000, 0x187ec},
{0x18800, 0x18af2},
{0x1b000, 0x1b001},
{0x1b000, 0x1b11e},
{0x1b170, 0x1b2fb},
{0x1f004, 0x1f004},
{0x1f0cf, 0x1f0cf},
{0x1f18e, 0x1f18e},
@@ -1482,6 +1483,7 @@ utf_char2cells(int c)
{0x1f210, 0x1f23b},
{0x1f240, 0x1f248},
{0x1f250, 0x1f251},
{0x1f260, 0x1f265},
{0x1f300, 0x1f320},
{0x1f32d, 0x1f335},
{0x1f337, 0x1f37c},
@@ -1504,15 +1506,13 @@ utf_char2cells(int c)
{0x1f6cc, 0x1f6cc},
{0x1f6d0, 0x1f6d2},
{0x1f6eb, 0x1f6ec},
{0x1f6f4, 0x1f6f6},
{0x1f910, 0x1f91e},
{0x1f920, 0x1f927},
{0x1f930, 0x1f930},
{0x1f933, 0x1f93e},
{0x1f940, 0x1f94b},
{0x1f950, 0x1f95e},
{0x1f980, 0x1f991},
{0x1f6f4, 0x1f6f8},
{0x1f910, 0x1f93e},
{0x1f940, 0x1f94c},
{0x1f950, 0x1f96b},
{0x1f980, 0x1f997},
{0x1f9c0, 0x1f9c0},
{0x1f9d0, 0x1f9e6},
{0x20000, 0x2fffd},
{0x30000, 0x3fffd}
};
@@ -1522,25 +1522,45 @@ utf_char2cells(int c)
* based on http://unicode.org/emoji/charts/emoji-list.html */
static struct interval emoji_width[] =
{
{0x1f004, 0x1f004},
{0x1f0cf, 0x1f0cf},
{0x1f1e6, 0x1f1ff},
{0x1f300, 0x1f320},
{0x1f330, 0x1f335},
{0x1f337, 0x1f37c},
{0x1f380, 0x1f393},
{0x1f3a0, 0x1f3c4},
{0x1f3c6, 0x1f3ca},
{0x1f3e0, 0x1f3f0},
{0x1f400, 0x1f43e},
{0x1f440, 0x1f440},
{0x1f442, 0x1f4f7},
{0x1f4f9, 0x1f4fc},
{0x1f500, 0x1f53d},
{0x1f550, 0x1f567},
{0x1f5fb, 0x1f640},
{0x1f645, 0x1f64f},
{0x1f680, 0x1f6c5}
{0x1f321, 0x1f321},
{0x1f324, 0x1f32c},
{0x1f336, 0x1f336},
{0x1f37d, 0x1f37d},
{0x1f396, 0x1f397},
{0x1f399, 0x1f39b},
{0x1f39e, 0x1f39f},
{0x1f3cb, 0x1f3ce},
{0x1f3d4, 0x1f3df},
{0x1f3f3, 0x1f3f5},
{0x1f3f7, 0x1f3f7},
{0x1f43f, 0x1f43f},
{0x1f441, 0x1f441},
{0x1f4fd, 0x1f4fd},
{0x1f549, 0x1f54a},
{0x1f56f, 0x1f570},
{0x1f573, 0x1f579},
{0x1f587, 0x1f587},
{0x1f58a, 0x1f58d},
{0x1f590, 0x1f590},
{0x1f5a5, 0x1f5a5},
{0x1f5a8, 0x1f5a8},
{0x1f5b1, 0x1f5b2},
{0x1f5bc, 0x1f5bc},
{0x1f5c2, 0x1f5c4},
{0x1f5d1, 0x1f5d3},
{0x1f5dc, 0x1f5de},
{0x1f5e1, 0x1f5e1},
{0x1f5e3, 0x1f5e3},
{0x1f5e8, 0x1f5e8},
{0x1f5ef, 0x1f5ef},
{0x1f5f3, 0x1f5f3},
{0x1f5fa, 0x1f5fa},
{0x1f6cb, 0x1f6cf},
{0x1f6e0, 0x1f6e5},
{0x1f6e9, 0x1f6e9},
{0x1f6f0, 0x1f6f0},
{0x1f6f3, 0x1f6f3}
};
if (c >= 0x100)
@@ -2338,6 +2358,7 @@ utf_iscomposing(int c)
{0x0ac7, 0x0ac9},
{0x0acb, 0x0acd},
{0x0ae2, 0x0ae3},
{0x0afa, 0x0aff},
{0x0b01, 0x0b03},
{0x0b3c, 0x0b3c},
{0x0b3e, 0x0b44},
@@ -2363,7 +2384,8 @@ utf_iscomposing(int c)
{0x0cca, 0x0ccd},
{0x0cd5, 0x0cd6},
{0x0ce2, 0x0ce3},
{0x0d01, 0x0d03},
{0x0d00, 0x0d03},
{0x0d3b, 0x0d3c},
{0x0d3e, 0x0d44},
{0x0d46, 0x0d48},
{0x0d4a, 0x0d4d},
@@ -2429,8 +2451,8 @@ utf_iscomposing(int c)
{0x1cd4, 0x1ce8},
{0x1ced, 0x1ced},
{0x1cf2, 0x1cf4},
{0x1cf8, 0x1cf9},
{0x1dc0, 0x1df5},
{0x1cf7, 0x1cf9},
{0x1dc0, 0x1df9},
{0x1dfb, 0x1dff},
{0x20d0, 0x20f0},
{0x2cef, 0x2cf1},
@@ -2509,10 +2531,21 @@ utf_iscomposing(int c)
{0x11630, 0x11640},
{0x116ab, 0x116b7},
{0x1171d, 0x1172b},
{0x11a01, 0x11a0a},
{0x11a33, 0x11a39},
{0x11a3b, 0x11a3e},
{0x11a47, 0x11a47},
{0x11a51, 0x11a5b},
{0x11a8a, 0x11a99},
{0x11c2f, 0x11c36},
{0x11c38, 0x11c3f},
{0x11c92, 0x11ca7},
{0x11ca9, 0x11cb6},
{0x11d31, 0x11d36},
{0x11d3a, 0x11d3a},
{0x11d3c, 0x11d3d},
{0x11d3f, 0x11d45},
{0x11d47, 0x11d47},
{0x16af0, 0x16af4},
{0x16b30, 0x16b36},
{0x16f51, 0x16f7e},
@@ -2583,6 +2616,7 @@ static struct interval emoji_all[] =
{0x2328, 0x2328},
{0x23cf, 0x23cf},
{0x23e9, 0x23f3},
{0x23f8, 0x23fa},
{0x24c2, 0x24c2},
{0x25aa, 0x25ab},
{0x25b6, 0x25b6},
@@ -2600,6 +2634,8 @@ static struct interval emoji_all[] =
{0x262a, 0x262a},
{0x262e, 0x262f},
{0x2638, 0x263a},
{0x2640, 0x2640},
{0x2642, 0x2642},
{0x2648, 0x2653},
{0x2660, 0x2660},
{0x2663, 0x2663},
@@ -2607,8 +2643,7 @@ static struct interval emoji_all[] =
{0x2668, 0x2668},
{0x267b, 0x267b},
{0x267f, 0x267f},
{0x2692, 0x2694},
{0x2696, 0x2697},
{0x2692, 0x2697},
{0x2699, 0x2699},
{0x269b, 0x269c},
{0x26a0, 0x26a1},
@@ -2667,22 +2702,50 @@ static struct interval emoji_all[] =
{0x1f22f, 0x1f22f},
{0x1f232, 0x1f23a},
{0x1f250, 0x1f251},
{0x1f300, 0x1f320},
{0x1f330, 0x1f335},
{0x1f337, 0x1f37c},
{0x1f380, 0x1f393},
{0x1f3a0, 0x1f3c4},
{0x1f3c6, 0x1f3ca},
{0x1f3e0, 0x1f3f0},
{0x1f400, 0x1f43e},
{0x1f440, 0x1f440},
{0x1f442, 0x1f4f7},
{0x1f4f9, 0x1f4fc},
{0x1f500, 0x1f53d},
{0x1f300, 0x1f321},
{0x1f324, 0x1f393},
{0x1f396, 0x1f397},
{0x1f399, 0x1f39b},
{0x1f39e, 0x1f3f0},
{0x1f3f3, 0x1f3f5},
{0x1f3f7, 0x1f4fd},
{0x1f4ff, 0x1f53d},
{0x1f549, 0x1f54e},
{0x1f550, 0x1f567},
{0x1f5fb, 0x1f640},
{0x1f645, 0x1f64f},
{0x1f680, 0x1f6c5}
{0x1f56f, 0x1f570},
{0x1f573, 0x1f57a},
{0x1f587, 0x1f587},
{0x1f58a, 0x1f58d},
{0x1f590, 0x1f590},
{0x1f595, 0x1f596},
{0x1f5a4, 0x1f5a5},
{0x1f5a8, 0x1f5a8},
{0x1f5b1, 0x1f5b2},
{0x1f5bc, 0x1f5bc},
{0x1f5c2, 0x1f5c4},
{0x1f5d1, 0x1f5d3},
{0x1f5dc, 0x1f5de},
{0x1f5e1, 0x1f5e1},
{0x1f5e3, 0x1f5e3},
{0x1f5e8, 0x1f5e8},
{0x1f5ef, 0x1f5ef},
{0x1f5f3, 0x1f5f3},
{0x1f5fa, 0x1f64f},
{0x1f680, 0x1f6c5},
{0x1f6cb, 0x1f6d2},
{0x1f6e0, 0x1f6e5},
{0x1f6e9, 0x1f6e9},
{0x1f6eb, 0x1f6ec},
{0x1f6f0, 0x1f6f0},
{0x1f6f3, 0x1f6f8},
{0x1f910, 0x1f93a},
{0x1f93c, 0x1f93e},
{0x1f940, 0x1f945},
{0x1f947, 0x1f94c},
{0x1f950, 0x1f96b},
{0x1f980, 0x1f997},
{0x1f9c0, 0x1f9c0},
{0x1f9d0, 0x1f9e6}
};
/*

View File

@@ -5477,6 +5477,14 @@ nv_clear(cmdarg_T *cap)
#ifdef FEAT_SYN_HL
/* Clear all syntax states to force resyncing. */
syn_stack_free_all(curwin->w_s);
# ifdef FEAT_RELTIME
{
win_T *wp;
FOR_ALL_WINDOWS(wp)
wp->w_s->b_syn_slow = FALSE;
}
# endif
#endif
redraw_later(CLEAR);
}

View File

@@ -6009,6 +6009,9 @@ did_set_string_option(
/* set when changing an option that only requires a redraw in the GUI */
int redraw_gui_only = FALSE;
#endif
#ifdef FEAT_AUTOCMD
int ft_changed = FALSE;
#endif
/* Get the global option to compare with, otherwise we would have to check
* two values for all local options. */
@@ -7418,6 +7421,8 @@ did_set_string_option(
{
if (!valid_filetype(*varp))
errmsg = e_invarg;
else
ft_changed = STRCMP(oldval, *varp) != 0;
}
#endif
@@ -7531,10 +7536,15 @@ did_set_string_option(
# endif
else if (varp == &(curbuf->b_p_ft))
{
/* 'filetype' is set, trigger the FileType autocommand */
did_filetype = TRUE;
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
/* 'filetype' is set, trigger the FileType autocommand.
* Skip this when called from a modeline and the filetype was
* already set to this value. */
if (!(opt_flags & OPT_MODELINE) || ft_changed)
{
did_filetype = TRUE;
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
curbuf->b_fname, TRUE, curbuf);
}
}
#endif
#ifdef FEAT_SPELL

View File

@@ -1,5 +1,5 @@
/* syntax.c */
void syntax_start(win_T *wp, linenr_T lnum);
void syntax_start(win_T *wp, linenr_T lnum, proftime_T *syntax_tm);
void syn_stack_free_all(synblock_T *block);
void syn_stack_apply_changes(buf_T *buf);
void syntax_end_parsing(linenr_T lnum);

View File

@@ -5756,8 +5756,6 @@ regmatch(
printf("Premature EOL\n");
#endif
}
if (status == RA_FAIL)
got_int = TRUE;
return (status == RA_MATCH);
}
@@ -8224,8 +8222,6 @@ report_re_switch(char_u *pat)
}
#endif
static int vim_regexec_both(regmatch_T *rmp, char_u *line, colnr_T col, int nl);
/*
* Match a regexp against a string.
* "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
@@ -8236,7 +8232,7 @@ static int vim_regexec_both(regmatch_T *rmp, char_u *line, colnr_T col, int nl);
* Return TRUE if there is a match, FALSE if not.
*/
static int
vim_regexec_both(
vim_regexec_string(
regmatch_T *rmp,
char_u *line, /* string to match against */
colnr_T col, /* column to start looking for match */
@@ -8299,12 +8295,12 @@ vim_regexec_prog(
char_u *line,
colnr_T col)
{
int r;
regmatch_T regmatch;
int r;
regmatch_T regmatch;
regmatch.regprog = *prog;
regmatch.rm_ic = ignore_case;
r = vim_regexec_both(&regmatch, line, col, FALSE);
r = vim_regexec_string(&regmatch, line, col, FALSE);
*prog = regmatch.regprog;
return r;
}
@@ -8316,7 +8312,7 @@ vim_regexec_prog(
int
vim_regexec(regmatch_T *rmp, char_u *line, colnr_T col)
{
return vim_regexec_both(rmp, line, col, FALSE);
return vim_regexec_string(rmp, line, col, FALSE);
}
#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
@@ -8329,7 +8325,7 @@ vim_regexec(regmatch_T *rmp, char_u *line, colnr_T col)
int
vim_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col)
{
return vim_regexec_both(rmp, line, col, TRUE);
return vim_regexec_string(rmp, line, col, TRUE);
}
#endif

View File

@@ -124,7 +124,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
static void fill_foldcolumn(char_u *p, win_T *wp, int closed, linenr_T lnum);
static void copy_text_attr(int off, char_u *buf, int len, int attr);
#endif
static int win_line(win_T *, linenr_T, int, int, int nochange);
static int win_line(win_T *, linenr_T, int, int, int nochange, proftime_T *syntax_tm);
static int char_needs_redraw(int off_from, int off_to, int cols);
#ifdef FEAT_RIGHTLEFT
static void screen_line(int row, int coloff, int endcol, int clear_width, int rlflag);
@@ -185,6 +185,11 @@ static void win_redr_ruler(win_T *wp, int always);
static int screen_char_attr = 0;
#endif
#if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME)
/* Can limit syntax highlight time to 'redrawtime'. */
# define SYN_TIME_LIMIT 1
#endif
/*
* Redraw the current window later, with update_screen(type).
* Set must_redraw only if not already set to a higher value.
@@ -923,6 +928,9 @@ update_single_line(win_T *wp, linenr_T lnum)
{
int row;
int j;
#ifdef SYN_TIME_LIMIT
proftime_T syntax_tm;
#endif
/* Don't do anything if the screen structures are (not yet) valid. */
if (!screen_valid(TRUE) || updating_screen)
@@ -931,6 +939,10 @@ update_single_line(win_T *wp, linenr_T lnum)
if (lnum >= wp->w_topline && lnum < wp->w_botline
&& foldedCount(wp, lnum, &win_foldinfo) == 0)
{
#ifdef SYN_TIME_LIMIT
/* Set the time limit to 'redrawtime'. */
profile_setlimit(p_rdt, &syntax_tm);
#endif
update_prepare();
row = 0;
@@ -944,7 +956,13 @@ update_single_line(win_T *wp, linenr_T lnum)
start_search_hl();
prepare_search_hl(wp, lnum);
# endif
win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, FALSE);
win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, FALSE,
#ifdef SYN_TIME_LIMIT
&syntax_tm
#else
NULL
#endif
);
# if defined(FEAT_SEARCH_EXTRA)
end_search_hl();
# endif
@@ -1140,6 +1158,9 @@ win_update(win_T *wp)
#if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA)
int save_got_int;
#endif
#ifdef SYN_TIME_LIMIT
proftime_T syntax_tm;
#endif
type = wp->w_redr_type;
@@ -1792,6 +1813,10 @@ win_update(win_T *wp)
save_got_int = got_int;
got_int = 0;
#endif
#ifdef SYN_TIME_LIMIT
/* Set the time limit to 'redrawtime'. */
profile_setlimit(p_rdt, &syntax_tm);
#endif
#ifdef FEAT_FOLDING
win_foldinfo.fi_level = 0;
#endif
@@ -2086,7 +2111,13 @@ win_update(win_T *wp)
/*
* Display one line.
*/
row = win_line(wp, lnum, srow, wp->w_height, mod_top == 0);
row = win_line(wp, lnum, srow, wp->w_height, mod_top == 0,
#ifdef SYN_TIME_LIMIT
&syntax_tm
#else
NULL
#endif
);
#ifdef FEAT_FOLDING
wp->w_lines[idx].wl_folded = FALSE;
@@ -2957,7 +2988,8 @@ win_line(
linenr_T lnum,
int startrow,
int endrow,
int nochange UNUSED) /* not updating for changed text */
int nochange UNUSED, /* not updating for changed text */
proftime_T *syntax_tm)
{
int col = 0; /* visual column on screen */
unsigned off; /* offset in ScreenLines/ScreenAttrs */
@@ -3158,20 +3190,29 @@ win_line(
extra_check = 0;
#endif
#ifdef FEAT_SYN_HL
if (syntax_present(wp) && !wp->w_s->b_syn_error)
if (syntax_present(wp) && !wp->w_s->b_syn_error
# ifdef SYN_TIME_LIMIT
&& !wp->w_s->b_syn_slow
# endif
)
{
/* Prepare for syntax highlighting in this line. When there is an
* error, stop syntax highlighting. */
save_did_emsg = did_emsg;
did_emsg = FALSE;
syntax_start(wp, lnum);
syntax_start(wp, lnum, syntax_tm);
if (did_emsg)
wp->w_s->b_syn_error = TRUE;
else
{
did_emsg = save_did_emsg;
has_syntax = TRUE;
extra_check = TRUE;
#ifdef SYN_TIME_LIMIT
if (!wp->w_s->b_syn_slow)
#endif
{
has_syntax = TRUE;
extra_check = TRUE;
}
}
}
@@ -3548,7 +3589,7 @@ win_line(
# ifdef FEAT_SYN_HL
/* Need to restart syntax highlighting for this line. */
if (has_syntax)
syntax_start(wp, lnum);
syntax_start(wp, lnum, syntax_tm);
# endif
}
#endif
@@ -4491,6 +4532,10 @@ win_line(
}
else
did_emsg = save_did_emsg;
#ifdef SYN_TIME_LIMIT
if (wp->w_s->b_syn_slow)
has_syntax = FALSE;
#endif
/* Need to get the line again, a multi-line regexp may
* have made it invalid. */

View File

@@ -1797,6 +1797,9 @@ typedef struct {
hashtab_T b_keywtab; /* syntax keywords hash table */
hashtab_T b_keywtab_ic; /* idem, ignore case */
int b_syn_error; /* TRUE when error occurred in HL */
# ifdef FEAT_RELTIME
int b_syn_slow; /* TRUE when 'redrawtime' reached */
# endif
int b_syn_ic; /* ignore case for :syn cmds */
int b_syn_spell; /* SYNSPL_ values */
garray_T b_syn_patterns; /* table for syntax patterns */

View File

@@ -367,6 +367,9 @@ static reg_extmatch_T *next_match_extmatch = NULL;
static win_T *syn_win; /* current window for highlighting */
static buf_T *syn_buf; /* current buffer for highlighting */
static synblock_T *syn_block; /* current buffer for highlighting */
#ifdef FEAT_RELTIME
static proftime_T *syn_tm;
#endif
static linenr_T current_lnum = 0; /* lnum of current state */
static colnr_T current_col = 0; /* column of current state */
static int current_state_stored = 0; /* TRUE if stored current state
@@ -494,7 +497,7 @@ static void syn_incl_toplevel(int id, int *flagsp);
* window.
*/
void
syntax_start(win_T *wp, linenr_T lnum)
syntax_start(win_T *wp, linenr_T lnum, proftime_T *syntax_tm UNUSED)
{
synstate_T *p;
synstate_T *last_valid = NULL;
@@ -524,6 +527,9 @@ syntax_start(win_T *wp, linenr_T lnum)
}
changedtick = CHANGEDTICK(syn_buf);
syn_win = wp;
#ifdef FEAT_RELTIME
syn_tm = syntax_tm;
#endif
/*
* Allocate syntax stack when needed.
@@ -3295,6 +3301,9 @@ syn_regexec(
syn_time_T *st UNUSED)
{
int r;
#ifdef FEAT_RELTIME
int timed_out = FALSE;
#endif
#ifdef FEAT_PROFILE
proftime_T pt;
@@ -3303,7 +3312,13 @@ syn_regexec(
#endif
rmp->rmm_maxcol = syn_buf->b_p_smc;
r = vim_regexec_multi(rmp, syn_win, syn_buf, lnum, col, NULL, NULL);
r = vim_regexec_multi(rmp, syn_win, syn_buf, lnum, col,
#ifdef FEAT_RELTIME
syn_tm, &timed_out
#else
NULL, NULL
#endif
);
#ifdef FEAT_PROFILE
if (syn_time_on)
@@ -3317,6 +3332,10 @@ syn_regexec(
++st->match;
}
#endif
#ifdef FEAT_RELTIME
if (timed_out)
syn_win->w_s->b_syn_slow = TRUE;
#endif
if (r > 0)
{
@@ -3575,6 +3594,9 @@ syntax_clear(synblock_T *block)
int i;
block->b_syn_error = FALSE; /* clear previous error */
#ifdef FEAT_RELTIME
block->b_syn_slow = FALSE; /* clear previous timeout */
#endif
block->b_syn_ic = FALSE; /* Use case, by default */
block->b_syn_spell = SYNSPL_DEFAULT; /* default spell checking */
block->b_syn_containedin = FALSE;
@@ -6542,7 +6564,7 @@ syn_get_id(
if (wp->w_buffer != syn_buf
|| lnum != current_lnum
|| col < current_col)
syntax_start(wp, lnum);
syntax_start(wp, lnum, NULL);
else if (wp->w_buffer == syn_buf
&& lnum == current_lnum
&& col > current_col)
@@ -6611,9 +6633,14 @@ syn_get_foldlevel(win_T *wp, long lnum)
int i;
/* Return quickly when there are no fold items at all. */
if (wp->w_s->b_syn_folditems != 0)
if (wp->w_s->b_syn_folditems != 0
&& !wp->w_s->b_syn_error
# ifdef SYN_TIME_LIMIT
&& !wp->w_s->b_syn_slow
# endif
)
{
syntax_start(wp, lnum);
syntax_start(wp, lnum, NULL);
for (i = 0; i < current_state.ga_len; ++i)
if (CUR_STATE(i).si_flags & HL_FOLD)
@@ -6882,6 +6909,7 @@ static char *(highlight_init_both[]) =
"Cursor guibg=fg guifg=bg",
"lCursor guibg=fg guifg=bg", /* should be different, but what? */
#endif
"default link QuickFixLine Search",
NULL
};
@@ -6970,8 +6998,6 @@ static char *(highlight_init_light[]) =
#ifdef FEAT_GUI
"Normal gui=NONE",
#endif
CENT("QuickFixLine term=reverse ctermbg=Cyan",
"QuickFixLine term=reverse ctermbg=Cyan guibg=Cyan"),
NULL
};
@@ -7057,8 +7083,6 @@ static char *(highlight_init_dark[]) =
CENT("Conceal ctermbg=DarkGrey ctermfg=LightGrey",
"Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey"),
#endif
CENT("QuickFixLine term=reverse ctermbg=Cyan",
"QuickFixLine term=reverse ctermbg=Cyan guibg=Cyan"),
#ifdef FEAT_GUI
"Normal gui=NONE",
#endif

View File

@@ -424,3 +424,37 @@ func Test_bg_detection()
hi Normal ctermbg=12
call assert_equal('dark', &bg)
endfunc
func Test_syntax_hangs()
if !has('reltime') || !has('float') || !has('syntax')
return
endif
" This pattern takes a long time to match, it should timeout.
new
call setline(1, ['aaa', repeat('abc ', 1000), 'ccc'])
let start = reltime()
set nolazyredraw redrawtime=101
syn match Error /\%#=1a*.*X\@<=b*/
redraw
let elapsed = reltimefloat(reltime(start))
call assert_true(elapsed > 0.1)
call assert_true(elapsed < 1.0)
" second time syntax HL is disabled
let start = reltime()
redraw
let elapsed = reltimefloat(reltime(start))
call assert_true(elapsed < 0.1)
" after CTRL-L the timeout flag is reset
let start = reltime()
exe "normal \<C-L>"
redraw
let elapsed = reltimefloat(reltime(start))
call assert_true(elapsed > 0.1)
call assert_true(elapsed < 1.0)
set redrawtime&
bwipe!
endfunc

View File

@@ -1363,6 +1363,52 @@ func Test_bitwise_functions()
call assert_fails("call invert({})", 'E728:')
endfunc
" Test trailing text after :endfunction {{{1
func Test_endfunction_trailing()
call assert_false(exists('*Xtest'))
exe "func Xtest()\necho 'hello'\nendfunc\nlet done = 'yes'"
call assert_true(exists('*Xtest'))
call assert_equal('yes', done)
delfunc Xtest
unlet done
exe "func Xtest()\necho 'hello'\nendfunc|let done = 'yes'"
call assert_true(exists('*Xtest'))
call assert_equal('yes', done)
delfunc Xtest
unlet done
set verbose=1
exe "func Xtest()\necho 'hello'\nendfunc \" garbage"
call assert_true(exists('*Xtest'))
delfunc Xtest
call assert_fails("func Xtest()\necho 'hello'\nendfunc garbage", 'E946')
call assert_true(exists('*Xtest'))
delfunc Xtest
set verbose=0
endfunc
func Test_delfunction_force()
delfunc! Xtest
delfunc! Xtest
func Xtest()
echo 'nothing'
endfunc
delfunc! Xtest
delfunc! Xtest
endfunc
" Test using bang after user command {{{1
func Test_user_command_with_bang()
command -bang Nieuw let nieuw = 1
Ni!
call assert_equal(1, nieuw)
unlet nieuw
delcommand Nieuw
endfunc
"-------------------------------------------------------------------------------
" Modelines {{{1
" vim: ts=8 sw=4 tw=80 fdm=marker

View File

@@ -2130,6 +2130,14 @@ ex_function(exarg_T *eap)
/* Check for "endfunction". */
if (checkforcmd(&p, "endfunction", 4) && nesting-- == 0)
{
if (*p == '|')
/* Another command follows. */
eap->nextcmd = vim_strsave(p + 1);
else if (line_arg != NULL && *skipwhite(line_arg) != NUL)
/* Another command follows. */
eap->nextcmd = line_arg;
else if (*p != NUL && *p != '"' && p_verbose > 0)
EMSG2((char_u *)_("E946: Text found after :endfunction: %s"), p);
if (line_arg == NULL)
vim_free(theline);
break;
@@ -2799,7 +2807,8 @@ ex_delfunction(exarg_T *eap)
{
if (fp == NULL)
{
EMSG2(_(e_nofunc), eap->arg);
if (!eap->forceit)
EMSG2(_(e_nofunc), eap->arg);
return;
}
if (fp->uf_calls > 0)

View File

@@ -764,6 +764,26 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
656,
/**/
655,
/**/
654,
/**/
653,
/**/
652,
/**/
651,
/**/
650,
/**/
649,
/**/
648,
/**/
647,
/**/
646,
/**/