Mercurial > vim
view runtime/syntax/eruby.vim @ 21566:1e3e5058041c v8.2.1333
patch 8.2.1333: Vim9: memory leak when using nested global function
Commit: https://github.com/vim/vim/commit/af8edbb8dc551aaf2105a4d77b3d8495da239ef0
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 1 00:03:09 2020 +0200
patch 8.2.1333: Vim9: memory leak when using nested global function
Problem: Vim9: memory leak when using nested global function.
Solution: Swap from and to when copying the lines.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 01 Aug 2020 00:15:04 +0200 |
parents | f0f06837a699 |
children | e3d6184b89fa |
line wrap: on
line source
" Vim syntax file " Language: eRuby " Maintainer: Tim Pope <vimNOSPAM@tpope.org> " URL: https://github.com/vim-ruby/vim-ruby " Release Coordinator: Doug Kearns <dougkearns@gmail.com> " Last Change: 2018 Jul 04 if &syntax !~# '\<eruby\>' || get(b:, 'current_syntax') =~# '\<eruby\>' finish endif if !exists("main_syntax") let main_syntax = 'eruby' endif if !exists("g:eruby_default_subtype") let g:eruby_default_subtype = "html" endif if &filetype =~ '^eruby\.' let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+') elseif &filetype =~ '^.*\.eruby\>' let b:eruby_subtype = matchstr(&filetype,'^.\{-\}\ze\.eruby\>') elseif !exists("b:eruby_subtype") && main_syntax == 'eruby' let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$") let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+') if b:eruby_subtype == '' let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\|\.example\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$') endif if b:eruby_subtype == 'rhtml' let b:eruby_subtype = 'html' elseif b:eruby_subtype == 'rb' let b:eruby_subtype = 'ruby' elseif b:eruby_subtype == 'yml' let b:eruby_subtype = 'yaml' elseif b:eruby_subtype == 'js' let b:eruby_subtype = 'javascript' elseif b:eruby_subtype == 'txt' " Conventional; not a real file type let b:eruby_subtype = 'text' elseif b:eruby_subtype == '' let b:eruby_subtype = g:eruby_default_subtype endif endif if !exists("b:eruby_nest_level") if &syntax =~# '\<eruby\.eruby\>' let b:eruby_nest_level = strlen(substitute(substitute(&filetype,'\C\<eruby\>','@','g'),'[^@]','','g')) else let b:eruby_nest_level = strlen(substitute(substitute(substitute(expand("%:t"),'@','','g'),'\c\.\%(erb\|rhtml\)\>','@','g'),'[^@]','','g')) endif endif if !b:eruby_nest_level let b:eruby_nest_level = 1 endif if get(b:, 'eruby_subtype', '') !~# '^\%(eruby\)\=$' && &syntax =~# '^eruby\>' exe "runtime! syntax/".b:eruby_subtype.".vim" endif unlet! b:current_syntax syn include @rubyTop syntax/ruby.vim syn cluster erubyRegions contains=erubyOneLiner,erubyBlock,erubyExpression,erubyComment exe 'syn region erubyOneLiner matchgroup=erubyDelimiter start="^%\{1,'.b:eruby_nest_level.'\}%\@!" end="$" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend oneline' exe 'syn region erubyBlock matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}%\@!-\=" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend' exe 'syn region erubyExpression matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}=\{1,4}" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend' exe 'syn region erubyComment matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}-\=#" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=rubyTodo,@Spell containedin=ALLBUT,@erubyRegions keepend' " Define the default highlighting. hi def link erubyDelimiter PreProc hi def link erubyComment Comment let b:current_syntax = matchstr(&syntax, '^.*\<eruby\>') if main_syntax == 'eruby' unlet main_syntax endif " vim: nowrap sw=2 sts=2 ts=8: