Update runtime files

This commit is contained in:
Bram Moolenaar
2023-02-27 15:49:53 +00:00
parent 341f3876b3
commit dd60c365cd
35 changed files with 686 additions and 206 deletions

View File

@ -1121,13 +1121,8 @@ def Is_IN_KeywordForLoop(line_1: string, line_2: string): bool # {{{3
enddef
def InCommentOrString(): bool # {{{3
for synID: number in synstack('.', col('.'))
if synIDattr(synID, 'name') =~ '\ccomment\|string\|heredoc'
return true
endif
endfor
return false
return synstack('.', col('.'))
->indexof((_, id: number): bool => synIDattr(id, 'name') =~ '\ccomment\|string\|heredoc') >= 0
enddef
def AlsoClosesBlock(line_B: dict<any>): bool # {{{3

View File

@ -22,8 +22,7 @@ let s:maxoff = 50 " maximum number of lines to look backwards for ()
function s:SearchBracket(fromlnum, flags)
return searchpairpos('[[({]', '', '[])}]', a:flags,
\ {-> synstack('.', col('.'))
\ ->map({_, id -> id->synIDattr('name')})
\ ->match('\%(Comment\|Todo\|String\)$') >= 0},
\ ->indexof({_, id -> synIDattr(id, 'name') =~ '\%(Comment\|Todo\|String\)$'}) >= 0},
\ [0, a:fromlnum - s:maxoff]->max(), g:python_indent.searchpair_timeout)
endfunction
@ -157,15 +156,13 @@ function python#GetIndent(lnum, ...)
" the start of the comment. synID() is slow, a linear search would take
" too long on a long line.
if synstack(plnum, pline_len)
\ ->map({_, id -> id->synIDattr('name')})
\ ->match('\%(Comment\|Todo\)$') >= 0
\ ->indexof({_, id -> synIDattr(id, 'name') =~ '\%(Comment\|Todo\)$'}) >= 0
let min = 1
let max = pline_len
while min < max
let col = (min + max) / 2
if synstack(plnum, col)
\ ->map({_, id -> id->synIDattr('name')})
\ ->match('\%(Comment\|Todo\)$') >= 0
\ ->indexof({_, id -> synIDattr(id, 'name') =~ '\%(Comment\|Todo\)$'}) >= 0
let max = col
else
let min = col + 1