mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #14640 from janlazo/vim-3ec3217f0491
vim-patch:3ec3217f0491,8.2.{2278,2885}
This commit is contained in:
commit
fd91e73c57
@ -759,13 +759,15 @@ three lines: >
|
||||
3:d<CR> is translated into: .,.+2d<CR>
|
||||
<
|
||||
|
||||
Visual Mode and Range *v_:*
|
||||
*:star-visual-range*
|
||||
Visual Mode and Range
|
||||
*v_:*
|
||||
{Visual}: Starts a command-line with the Visual selected lines as a
|
||||
range. The code `:'<,'>` is used for this range, which makes
|
||||
it possible to select a similar line from the command-line
|
||||
history for repeating a command on different Visually selected
|
||||
lines.
|
||||
|
||||
:* *:star* *:star-visual-range*
|
||||
When Visual mode was already ended, a short way to use the
|
||||
Visual area for a range is `:*`.
|
||||
|
||||
|
@ -360,6 +360,22 @@ Overview of which map command works in which mode. More details below.
|
||||
:cmap :cnoremap :cunmap Command-line
|
||||
:tmap :tnoremap :tunmap Terminal
|
||||
|
||||
Same information in a table:
|
||||
*map-table*
|
||||
Mode | Norm | Ins | Cmd | Vis | Sel | Opr | Term | Lang | ~
|
||||
Command +------+-----+-----+-----+-----+-----+------+------+ ~
|
||||
[nore]map | yes | - | - | yes | yes | yes | - | - |
|
||||
n[nore]map | yes | - | - | - | - | - | - | - |
|
||||
[nore]map! | - | yes | yes | - | - | - | - | - |
|
||||
i[nore]map | - | yes | - | - | - | - | - | - |
|
||||
c[nore]map | - | - | yes | - | - | - | - | - |
|
||||
v[nore]map | - | - | - | yes | yes | - | - | - |
|
||||
x[nore]map | - | - | - | yes | - | - | - | - |
|
||||
s[nore]map | - | - | - | - | yes | - | - | - |
|
||||
o[nore]map | - | - | - | - | - | yes | - | - |
|
||||
t[nore]map | - | - | - | - | - | - | yes | - |
|
||||
l[nore]map | - | yes | yes | - | - | - | - | yes |
|
||||
|
||||
|
||||
COMMANDS MODES ~
|
||||
Normal Visual+Select Operator-pending ~
|
||||
|
@ -1014,13 +1014,6 @@ commands can be combined to create a NewGrep command: >
|
||||
updated. With the [!] any changes in the current
|
||||
buffer are abandoned.
|
||||
|
||||
'f' When the 'f' flag is specified, fuzzy string
|
||||
matching is used to find matching lines. In this
|
||||
case, {pattern} is treated as a literal string
|
||||
instead of a regular expression. See
|
||||
|matchfuzzy()| for more info about fuzzy
|
||||
matching.
|
||||
|
||||
|QuickFixCmdPre| and |QuickFixCmdPost| are triggered.
|
||||
A file that is opened for matching may use a buffer
|
||||
number, but it is reused if possible to avoid
|
||||
|
@ -50,6 +50,11 @@ Multiple repeats *multi-repeat*
|
||||
:[range]v[global]/{pattern}/[cmd]
|
||||
Same as :g!.
|
||||
|
||||
Example: >
|
||||
:g/^Obsolete/d _
|
||||
Using the underscore after `:d` avoids clobbering registers or the clipboard.
|
||||
This also makes it faster.
|
||||
|
||||
Instead of the '/' which surrounds the {pattern}, you can use any other
|
||||
single byte character, but not an alphabetic character, '\', '"' or '|'.
|
||||
This is useful if you want to include a '/' in the search pattern or
|
||||
|
@ -1,6 +1,7 @@
|
||||
" Vim filetype plugin file
|
||||
" Language: meson
|
||||
" License: VIM License
|
||||
" Maintainer: Liam Beguin <liambeguin@gmail.com>
|
||||
" Original Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
||||
" Last Change: 2018 Nov 27
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
" Vim filetype plugin file
|
||||
" Language: SystemVerilog
|
||||
" Maintainer: kocha <kocha.lsifrontend@gmail.com>
|
||||
" Last Change: 12-Aug-2013.
|
||||
" Last Change: 07-May-2021
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
@ -9,3 +9,36 @@ endif
|
||||
|
||||
" Behaves just like Verilog
|
||||
runtime! ftplugin/verilog.vim
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Add SystemVerilog keywords for matchit plugin.
|
||||
if exists("loaded_matchit")
|
||||
let b:match_words =
|
||||
\ '\<begin\>:\<end\>,' .
|
||||
\ '\<case\>\|\<casex\>\|\<casez\>:\<endcase\>,' .
|
||||
\ '\<module\>:\<endmodule\>,' .
|
||||
\ '\<if\>:`\@<!\<else\>,' .
|
||||
\ '\<function\>:\<endfunction\>,' .
|
||||
\ '`ifn\?def\>:`elsif\>:`else\>:`endif\>,' .
|
||||
\ '\<task\>:\<endtask\>,' .
|
||||
\ '\<specify\>:\<endspecify\>,' .
|
||||
\ '\<config\>:\<endconfig\>,' .
|
||||
\ '\<generate\>:\<endgenerate\>,' .
|
||||
\ '\<fork\>:\<join\>\|\<join_any\>\|\<join_none\>,' .
|
||||
\ '\<primitive\>:\<endprimitive\>,' .
|
||||
\ '\<table\>:\<endtable\>,' .
|
||||
\ '\<checker\>:\<endchecker\>,' .
|
||||
\ '\<class\>:\<endclass\>,' .
|
||||
\ '\<clocking\>:\<endclocking\>,' .
|
||||
\ '\<gruop\>:\<endgruop\>,' .
|
||||
\ '\<interface\>:\<endinterface\>,' .
|
||||
\ '\<package\>:\<endpackage\>,' .
|
||||
\ '\<program\>:\<endprogram\>,' .
|
||||
\ '\<property\>:\<endproperty\>,' .
|
||||
\ '\<sequence\>:\<endsequence\>'
|
||||
endif
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
@ -2,6 +2,7 @@
|
||||
" Language: Meson
|
||||
" License: VIM License
|
||||
" Maintainer: Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
|
||||
" Liam Beguin <liambeguin@gmail.com>
|
||||
" Original Authors: David Bustos <bustos@caltech.edu>
|
||||
" Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2019 Oct 18
|
||||
|
@ -2,7 +2,7 @@
|
||||
"
|
||||
" Author: Bram Moolenaar
|
||||
" Copyright: Vim license applies, see ":help license"
|
||||
" Last Change: 2021 Jan 03
|
||||
" Last Change: 2021 May 16
|
||||
"
|
||||
" WORK IN PROGRESS - Only the basics work
|
||||
" Note: On MS-Windows you need a recent version of gdb. The one included with
|
||||
@ -246,7 +246,9 @@ func s:StartDebug_term(dict)
|
||||
let s:gdbbuf = gdb_job_info['buffer']
|
||||
let s:gdbwin = win_getid(winnr())
|
||||
|
||||
" Set arguments to be run
|
||||
" Set arguments to be run. First wait a bit to make detecting gdb a bit
|
||||
" more reliable.
|
||||
sleep 200m
|
||||
if len(proc_args)
|
||||
call chansend(s:gdb_job_id, 'set args ' . join(proc_args) . "\r")
|
||||
endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
" Vim syntax file
|
||||
" Language: dts/dtsi (device tree files)
|
||||
" Maintainer: Daniel Mack <vim@zonque.org>
|
||||
" Last Change: 2013 Oct 20
|
||||
" Last Change: 2021 May 15
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
@ -9,7 +9,7 @@ endif
|
||||
|
||||
syntax region dtsComment start="/\*" end="\*/"
|
||||
syntax match dtsReference "&[[:alpha:][:digit:]_]\+"
|
||||
syntax region dtsBinaryProperty start="\[" end="\]"
|
||||
syntax region dtsBinaryProperty start="\[" end="\]"
|
||||
syntax match dtsStringProperty "\".*\""
|
||||
syntax match dtsKeyword "/.\{-1,\}/"
|
||||
syntax match dtsLabel "^[[:space:]]*[[:alpha:][:digit:]_]\+:"
|
||||
@ -18,6 +18,38 @@ syntax region dtsCellProperty start="<" end=">" contains=dtsReference,dtsBinar
|
||||
syntax region dtsCommentInner start="/\*" end="\*/"
|
||||
syntax match dtsCommentLine "//.*$"
|
||||
|
||||
" Accept %: for # (C99)
|
||||
syn region cPreCondit start="^\s*\zs\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError
|
||||
syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>"
|
||||
if !exists("c_no_if0")
|
||||
syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip
|
||||
syn region cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold
|
||||
syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse
|
||||
if !exists("c_no_if0_fold")
|
||||
syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold
|
||||
else
|
||||
syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
|
||||
endif
|
||||
syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit
|
||||
syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold
|
||||
syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit
|
||||
if !exists("c_no_if0_fold")
|
||||
syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold
|
||||
else
|
||||
syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2
|
||||
endif
|
||||
syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
|
||||
syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip
|
||||
syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc
|
||||
endif
|
||||
syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
|
||||
syn match cIncluded display contained "<[^>]*>"
|
||||
syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
|
||||
"syn match cLineSkip "\\$"
|
||||
syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti,cBadBlock
|
||||
syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
|
||||
syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
|
||||
|
||||
hi def link dtsCellProperty Number
|
||||
hi def link dtsBinaryProperty Number
|
||||
hi def link dtsStringProperty String
|
||||
@ -26,5 +58,21 @@ hi def link dtsLabel Label
|
||||
hi def link dtsNode Structure
|
||||
hi def link dtsReference Macro
|
||||
hi def link dtsComment Comment
|
||||
hi def link dtsCommentInner Comment
|
||||
hi def link dtsCommentInner Comment
|
||||
hi def link dtsCommentLine Comment
|
||||
|
||||
hi def link cInclude Include
|
||||
hi def link cPreProc PreProc
|
||||
hi def link cDefine Macro
|
||||
hi def link cIncluded cString
|
||||
hi def link cString String
|
||||
|
||||
hi def link cCppInWrapper cCppOutWrapper
|
||||
hi def link cCppOutWrapper cPreCondit
|
||||
hi def link cPreConditMatch cPreCondit
|
||||
hi def link cPreCondit PreCondit
|
||||
hi def link cCppOutSkip cCppOutIf2
|
||||
|
||||
hi def link cCppInElse2 cCppOutIf2
|
||||
hi def link cCppOutIf2 cCppOut
|
||||
hi def link cCppOut Comment
|
||||
|
@ -2,6 +2,7 @@
|
||||
" Language: Meson
|
||||
" License: VIM License
|
||||
" Maintainer: Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
|
||||
" Liam Beguin <liambeguin@gmail.com>
|
||||
" Last Change: 2019 Oct 18
|
||||
" Credits: Zvezdan Petkovic <zpetkovic@acm.org>
|
||||
" Neil Schemenauer <nas@meson.ca>
|
||||
@ -17,11 +18,7 @@
|
||||
" let meson_space_error_highlight = 1
|
||||
"
|
||||
|
||||
" For version 5.x: Clear all syntax items.
|
||||
" For version 6.x: Quit when a syntax file was already loaded.
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
@ -32,8 +29,9 @@ set cpo&vim
|
||||
|
||||
" http://mesonbuild.com/Syntax.html
|
||||
syn keyword mesonConditional elif else if endif
|
||||
syn keyword mesonRepeat foreach endforeach
|
||||
syn keyword mesonOperator and not or
|
||||
syn keyword mesonRepeat foreach endforeach
|
||||
syn keyword mesonOperator and not or in
|
||||
syn keyword mesonStatement continue break
|
||||
|
||||
syn match mesonComment "#.*$" contains=mesonTodo,@Spell
|
||||
syn keyword mesonTodo FIXME NOTE NOTES TODO XXX contained
|
||||
@ -117,10 +115,12 @@ syn keyword mesonBuiltin
|
||||
\ subdir
|
||||
\ subdir_done
|
||||
\ subproject
|
||||
\ summary
|
||||
\ target_machine
|
||||
\ test
|
||||
\ vcs_tag
|
||||
\ warning
|
||||
\ range
|
||||
|
||||
if exists("meson_space_error_highlight")
|
||||
" trailing whitespace
|
||||
@ -130,31 +130,20 @@ if exists("meson_space_error_highlight")
|
||||
syn match mesonSpaceError display "\t\+ "
|
||||
endif
|
||||
|
||||
if version >= 508 || !exists("did_meson_syn_inits")
|
||||
if version <= 508
|
||||
let did_meson_syn_inits = 1
|
||||
command -nargs=+ HiLink hi link <args>
|
||||
else
|
||||
command -nargs=+ HiLink hi def link <args>
|
||||
endif
|
||||
|
||||
" The default highlight links. Can be overridden later.
|
||||
HiLink mesonStatement Statement
|
||||
HiLink mesonConditional Conditional
|
||||
HiLink mesonRepeat Repeat
|
||||
HiLink mesonOperator Operator
|
||||
HiLink mesonComment Comment
|
||||
HiLink mesonTodo Todo
|
||||
HiLink mesonString String
|
||||
HiLink mesonEscape Special
|
||||
HiLink mesonNumber Number
|
||||
HiLink mesonBuiltin Function
|
||||
HiLink mesonConstant Number
|
||||
if exists("meson_space_error_highlight")
|
||||
HiLink mesonSpaceError Error
|
||||
endif
|
||||
|
||||
delcommand HiLink
|
||||
" The default highlight links. Can be overridden later.
|
||||
hi def link mesonStatement Statement
|
||||
hi def link mesonConditional Conditional
|
||||
hi def link mesonRepeat Repeat
|
||||
hi def link mesonOperator Operator
|
||||
hi def link mesonComment Comment
|
||||
hi def link mesonTodo Todo
|
||||
hi def link mesonString String
|
||||
hi def link mesonEscape Special
|
||||
hi def link mesonNumber Number
|
||||
hi def link mesonBuiltin Function
|
||||
hi def link mesonConstant Number
|
||||
if exists("meson_space_error_higlight")
|
||||
hi def link mesonSpaceError Error
|
||||
endif
|
||||
|
||||
let b:current_syntax = "meson"
|
||||
|
@ -692,6 +692,7 @@ static char_u *regparse; ///< Input-scan pointer.
|
||||
static int prevchr_len; ///< byte length of previous char
|
||||
static int num_complex_braces; ///< Complex \{...} count
|
||||
static int regnpar; ///< () count.
|
||||
static bool wants_nfa; ///< regex should use NFA engine
|
||||
static int regnzpar; ///< \z() count.
|
||||
static int re_has_z; ///< \z item detected
|
||||
static char_u *regcode; ///< Code-emit pointer, or JUST_CALC_SIZE
|
||||
@ -3974,17 +3975,25 @@ static bool regmatch(
|
||||
|
||||
pos = getmark_buf(rex.reg_buf, mark, false);
|
||||
if (pos == NULL // mark doesn't exist
|
||||
|| pos->lnum <= 0 // mark isn't set in reg_buf
|
||||
|| (pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||
? (pos->col == (colnr_T)(rex.input - rex.line)
|
||||
? (cmp == '<' || cmp == '>')
|
||||
: (pos->col < (colnr_T)(rex.input - rex.line)
|
||||
? cmp != '>'
|
||||
: cmp != '<'))
|
||||
: (pos->lnum < rex.lnum + rex.reg_firstlnum
|
||||
? cmp != '>'
|
||||
: cmp != '<'))) {
|
||||
|| pos->lnum <= 0) { // mark isn't set in reg_buf
|
||||
status = RA_NOMATCH;
|
||||
} else {
|
||||
const colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||
&& pos->col == MAXCOL
|
||||
? (colnr_T)STRLEN(reg_getline(pos->lnum - rex.reg_firstlnum))
|
||||
: pos->col;
|
||||
|
||||
if (pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||
? (pos_col == (colnr_T)(rex.input - rex.line)
|
||||
? (cmp == '<' || cmp == '>')
|
||||
: (pos_col < (colnr_T)(rex.input - rex.line)
|
||||
? cmp != '>'
|
||||
: cmp != '<'))
|
||||
: (pos->lnum < rex.lnum + rex.reg_firstlnum
|
||||
? cmp != '>'
|
||||
: cmp != '<')) {
|
||||
status = RA_NOMATCH;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -7240,7 +7249,7 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
|
||||
// Check for error compiling regexp with initial engine.
|
||||
if (prog == NULL) {
|
||||
#ifdef BT_REGEXP_DEBUG_LOG
|
||||
// Debugging log for NFA.
|
||||
// Debugging log for BT engine.
|
||||
if (regexp_engine != BACKTRACKING_ENGINE) {
|
||||
FILE *f = fopen(BT_REGEXP_DEBUG_LOG_NAME, "a");
|
||||
if (f) {
|
||||
@ -7257,6 +7266,7 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
|
||||
// But don't try if an error message was given.
|
||||
if (regexp_engine == AUTOMATIC_ENGINE && !called_emsg) {
|
||||
regexp_engine = BACKTRACKING_ENGINE;
|
||||
report_re_switch(expr);
|
||||
prog = bt_regengine.regcomp(expr, re_flags);
|
||||
}
|
||||
}
|
||||
|
@ -328,6 +328,11 @@ static int *post_start; ///< holds the postfix form of r.e.
|
||||
static int *post_end;
|
||||
static int *post_ptr;
|
||||
|
||||
// Set when the pattern should use the NFA engine.
|
||||
// E.g. [[:upper:]] only allows 8bit characters for BT engine,
|
||||
// while NFA engine handles multibyte characters correctly.
|
||||
static bool wants_nfa;
|
||||
|
||||
static int nstate; ///< Number of states in the NFA. Also used when executing.
|
||||
static int istate; ///< Index in the state vector, used in alloc_state()
|
||||
|
||||
@ -377,6 +382,7 @@ nfa_regcomp_start (
|
||||
post_start = (int *)xmalloc(postfix_size);
|
||||
post_ptr = post_start;
|
||||
post_end = post_start + nstate_max;
|
||||
wants_nfa = false;
|
||||
rex.nfa_has_zend = false;
|
||||
rex.nfa_has_backref = false;
|
||||
|
||||
@ -1618,6 +1624,7 @@ collection:
|
||||
EMIT(NFA_CLASS_GRAPH);
|
||||
break;
|
||||
case CLASS_LOWER:
|
||||
wants_nfa = true;
|
||||
EMIT(NFA_CLASS_LOWER);
|
||||
break;
|
||||
case CLASS_PRINT:
|
||||
@ -1630,6 +1637,7 @@ collection:
|
||||
EMIT(NFA_CLASS_SPACE);
|
||||
break;
|
||||
case CLASS_UPPER:
|
||||
wants_nfa = true;
|
||||
EMIT(NFA_CLASS_UPPER);
|
||||
break;
|
||||
case CLASS_XDIGIT:
|
||||
@ -1998,10 +2006,17 @@ static int nfa_regpiece(void)
|
||||
return OK;
|
||||
}
|
||||
|
||||
// The engine is very inefficient (uses too many states) when the maximum
|
||||
// is much larger than the minimum and when the maximum is large. Bail out
|
||||
// if we can use the other engine.
|
||||
if ((nfa_re_flags & RE_AUTO) && (maxval > 500 || maxval > minval + 200)) {
|
||||
// The engine is very inefficient (uses too many states) when the
|
||||
// maximum is much larger than the minimum and when the maximum is
|
||||
// large. However, when maxval is MAX_LIMIT, it is okay, as this
|
||||
// will emit NFA_STAR.
|
||||
// Bail out if we can use the other engine, but only, when the
|
||||
// pattern does not need the NFA engine like (e.g. [[:upper:]]\{2,\}
|
||||
// does not work with with characters > 8 bit with the BT engine)
|
||||
if ((nfa_re_flags & RE_AUTO)
|
||||
&& (maxval > 500 || maxval > minval + 200)
|
||||
&& (maxval != MAX_LIMIT && minval < 200)
|
||||
&& !wants_nfa) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -6055,21 +6070,27 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
|
||||
{
|
||||
pos_T *pos = getmark_buf(rex.reg_buf, t->state->val, false);
|
||||
|
||||
// Compare the mark position to the match position.
|
||||
result = (pos != NULL // mark doesn't exist
|
||||
&& pos->lnum > 0 // mark isn't set in reg_buf
|
||||
&& (pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||
? (pos->col == (colnr_T)(rex.input - rex.line)
|
||||
? t->state->c == NFA_MARK
|
||||
: (pos->col < (colnr_T)(rex.input - rex.line)
|
||||
? t->state->c == NFA_MARK_GT
|
||||
: t->state->c == NFA_MARK_LT))
|
||||
: (pos->lnum < rex.lnum + rex.reg_firstlnum
|
||||
? t->state->c == NFA_MARK_GT
|
||||
: t->state->c == NFA_MARK_LT)));
|
||||
if (result) {
|
||||
add_here = true;
|
||||
add_state = t->state->out;
|
||||
// Compare the mark position to the match position, if the mark
|
||||
// exists and mark is set in reg_buf.
|
||||
if (pos != NULL && pos->lnum > 0) {
|
||||
const colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||
&& pos->col == MAXCOL
|
||||
? (colnr_T)STRLEN(reg_getline(pos->lnum - rex.reg_firstlnum))
|
||||
: pos->col;
|
||||
|
||||
result = pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||
? (pos_col == (colnr_T)(rex.input - rex.line)
|
||||
? t->state->c == NFA_MARK
|
||||
: (pos_col < (colnr_T)(rex.input - rex.line)
|
||||
? t->state->c == NFA_MARK_GT
|
||||
: t->state->c == NFA_MARK_LT))
|
||||
: (pos->lnum < rex.lnum + rex.reg_firstlnum
|
||||
? t->state->c == NFA_MARK_GT
|
||||
: t->state->c == NFA_MARK_LT);
|
||||
if (result) {
|
||||
add_here = true;
|
||||
add_state = t->state->out;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -542,6 +542,52 @@ func Test_match_start_of_line_combining()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Check that [[:upper:]] matches for automatic engine
|
||||
func Test_match_char_class_upper()
|
||||
new
|
||||
let _engine=®expengine
|
||||
|
||||
" Test 1: [[:upper:]]\{2,\}
|
||||
set regexpengine=0
|
||||
call setline(1, ['05. ПЕСНЯ О ГЕРОЯХ муз. А. Давиденко, М. Коваля и Б. Шехтера ...', '05. PJESNJA O GJEROJAKH mus. A. Davidjenko, M. Kovalja i B. Shjekhtjera ...'])
|
||||
call cursor(1,1)
|
||||
let search_cmd='norm /\<[[:upper:]]\{2,\}\>' .. "\<CR>"
|
||||
exe search_cmd
|
||||
call assert_equal(4, searchcount().total, 'TEST 1')
|
||||
set regexpengine=1
|
||||
exe search_cmd
|
||||
call assert_equal(2, searchcount().total, 'TEST 1')
|
||||
set regexpengine=2
|
||||
exe search_cmd
|
||||
call assert_equal(4, searchcount().total, 'TEST 1')
|
||||
|
||||
" Test 2: [[:upper:]].\+
|
||||
let search_cmd='norm /\<[[:upper:]].\+\>' .. "\<CR>"
|
||||
set regexpengine=0
|
||||
exe search_cmd
|
||||
call assert_equal(2, searchcount().total, 'TEST 2')
|
||||
set regexpengine=1
|
||||
exe search_cmd
|
||||
call assert_equal(1, searchcount().total, 'TEST 2')
|
||||
set regexpengine=2
|
||||
exe search_cmd
|
||||
call assert_equal(2, searchcount().total, 'TEST 2')
|
||||
|
||||
" Test 3: [[:lower:]]\+
|
||||
let search_cmd='norm /\<[[:lower:]]\+\>' .. "\<CR>"
|
||||
set regexpengine=0
|
||||
exe search_cmd
|
||||
call assert_equal(4, searchcount().total, 'TEST 3 lower')
|
||||
set regexpengine=1
|
||||
exe search_cmd
|
||||
call assert_equal(2, searchcount().total, 'TEST 3 lower')
|
||||
set regexpengine=2
|
||||
exe search_cmd
|
||||
call assert_equal(4, searchcount().total, 'TEST 3 lower')
|
||||
|
||||
" clean up
|
||||
let ®expengine=_engine
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@ -1177,13 +1177,28 @@ func Test_look_behind()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_search_visual_area_linewise()
|
||||
new
|
||||
call setline(1, ['aa', 'bb', 'cc'])
|
||||
exe "normal 2GV\<Esc>"
|
||||
for engine in [1, 2]
|
||||
exe 'set regexpengine=' .. engine
|
||||
exe "normal gg/\\%'<\<CR>>"
|
||||
call assert_equal([0, 2, 1, 0, 1], getcurpos(), 'engine ' .. engine)
|
||||
exe "normal gg/\\%'>\<CR>"
|
||||
call assert_equal([0, 2, 2, 0, 2], getcurpos(), 'engine ' .. engine)
|
||||
endfor
|
||||
|
||||
bwipe!
|
||||
set regexpengine&
|
||||
endfunc
|
||||
|
||||
func Test_search_sentence()
|
||||
new
|
||||
" this used to cause a crash
|
||||
call assert_fails("/\\%')", 'E486')
|
||||
call assert_fails("/", 'E486')
|
||||
/\%'(
|
||||
/
|
||||
bwipe
|
||||
endfunc
|
||||
|
||||
" Test that there is no crash when there is a last search pattern but no last
|
||||
|
Loading…
Reference in New Issue
Block a user