Refactor (minor) has_zs into extra_info struct

This commit is contained in:
Andy K. Massimino
2018-05-24 19:15:59 -04:00
parent 9b13392c73
commit 1763debff6
2 changed files with 16 additions and 3 deletions

View File

@@ -500,7 +500,7 @@ function! s:parser_delim_new(lnum, cnum, opts) " {{{1
endif
" if pattern may contain \zs, extra processing is required
let l:has_zs = l:rebrs[l:i / l:ns].has_zs
let l:has_zs = l:rebrs[l:i / l:ns].extra_info.has_zs
let l:mid_id = 0
for l:re in l:res
@@ -670,7 +670,7 @@ function! s:get_matching_delims(down, stopline) dict " {{{1
endif
" get the match and groups
let l:has_zs = self.regextwo.has_zs
let l:has_zs = self.regextwo.extra_info.has_zs
let l:re_anchored = s:anchor_regex(l:re, l:cnum_corr, l:has_zs)
let l:matches = matchlist(getline(l:lnum_corr), l:re_anchored)
let l:match_corr = l:matches[0]

View File

@@ -341,8 +341,17 @@ function! s:init_delim_lists(...) abort " {{{1
endif
endfor
" stores information for each word
let l:extra_list = repeat([{}], len(l:words))
" stores series-level information
let l:extra_info = {
\ 'has_zs': match(l:words_backref, g:matchup#re#zs) >= 0,
\}
" this is the original set of words plus the set of augments
" TODO this should probably be renamed
" (also called regexone)
call add(l:lists.delim_tex.regex, {
\ 'open' : l:words[0],
\ 'close' : l:words[-1],
@@ -353,6 +362,7 @@ function! s:init_delim_lists(...) abort " {{{1
" this list has \(groups\) and we also stuff recapture data
" TODO this should probably be renamed
" (also called regextwo)
call add(l:lists.delim_tex.regex_backref, {
\ 'open' : l:words_backref[0],
\ 'close' : l:words_backref[-1],
@@ -361,7 +371,8 @@ function! s:init_delim_lists(...) abort " {{{1
\ 'need_grp' : l:all_needed_groups,
\ 'grp_renu' : l:group_renumber,
\ 'aug_comp' : l:augment_comp,
\ 'has_zs' : match(l:words_backref, g:matchup#re#zs) >= 0,
\ 'extra_list' : l:extra_list,
\ 'extra_info' : l:extra_info,
\})
endfor
@@ -412,6 +423,8 @@ function! s:init_delim_lists_fast(mps) abort " {{{1
\ 'grp_renu' : {},
\ 'aug_comp' : {},
\ 'has_zs' : 0,
\ 'extra_list' : repeat([{}], len(l:words)),
\ 'extra_info' : { 'has_zs': 0, },
\})
endfor