From: Hiroshi Shirosaki Date: Fri, 19 Feb 2016 05:07:14 +0000 (+0900) Subject: Fix fenced code block syntax when reopening a file X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/156e0bfe4e68b01e28aee884bf4e69a34d3e7b1a?ds=sidebyside;hp=-c Fix fenced code block syntax when reopening a file Fix #259 --- 156e0bfe4e68b01e28aee884bf4e69a34d3e7b1a diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index e189ec4..c7fba7f 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -706,9 +706,16 @@ function! s:MarkdownRefreshSyntax(force) endif endfunction +function! s:MarkdownClearSyntaxVariables() + if &filetype == 'markdown' + unlet! b:mkd_included_filetypes + endif +endfunction + augroup Mkd autocmd! au BufWinEnter * call s:MarkdownRefreshSyntax(1) + au BufUnload * call s:MarkdownClearSyntaxVariables() au BufWritePost * call s:MarkdownRefreshSyntax(0) au InsertEnter,InsertLeave * call s:MarkdownRefreshSyntax(0) au CursorHold,CursorHoldI * call s:MarkdownRefreshSyntax(0) diff --git a/test/syntax.vader b/test/syntax.vader index 98548a0..fda56e0 100644 --- a/test/syntax.vader +++ b/test/syntax.vader @@ -437,6 +437,22 @@ Execute (fenced code block languages setting): AssertEqual SyntaxOf('foo'), 'csString' unlet g:vim_markdown_fenced_languages +Given markdown; +```vim +let g:a = 1 +``` + +Execute (fenced code block includes language syntax with reopening same buffer): + let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax') + call b:func(0) + split + quit + edit + set filetype=markdown + execute "normal! i```vim\let g:a = 1\```" + call b:func(1) + AssertEqual SyntaxOf('g:a'), 'vimVar' + Given markdown; ```a+b- code