From: Hiroshi Shirosaki Date: Wed, 13 Jan 2016 06:36:54 +0000 (+0900) Subject: Add `:Toc` tests for setex and atx headers X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/87633369306b4872c652faa56049a95660287047?ds=sidebyside Add `:Toc` tests for setex and atx headers `bufname()` is not needed for `getbufline()`. `bufname()` does not work with vader tests. Move `:Toc` tests to test/toc.vader. --- diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index f68e54c..7eb5784 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -330,7 +330,7 @@ function! s:Toc(...) let d.text = substitute(d.text, '\v[ ]*#*$', '', '') " setex headers else - let l:next_line = getbufline(bufname(d.bufnr), d.lnum+1) + let l:next_line = getbufline(d.bufnr, d.lnum+1) if match(l:next_line, "=") > -1 let l:level = 0 elseif match(l:next_line, "-") > -1 diff --git a/test/map.vader b/test/map.vader index e6d2dff..92947f5 100644 --- a/test/map.vader +++ b/test/map.vader @@ -112,16 +112,3 @@ Execute (]c): AssertEqual line('.'), 3 normal ]c AssertEqual line('.'), 1 - -Given markdown; -# a - -Execute (Toc does not set nomodifiable on other files): - " Sanity check. - Assert &modifiable - - :Toc - :lclose - :edit a - - Assert &modifiable diff --git a/test/toc.vader b/test/toc.vader new file mode 100644 index 0000000..64831e4 --- /dev/null +++ b/test/toc.vader @@ -0,0 +1,56 @@ +Given markdown; +# a + +Execute (Toc does not set nomodifiable on other files): + " Sanity check. + Assert &modifiable + + :Toc + :lclose + :edit a + + Assert &modifiable + +Given markdown; +header 1 +======== + +test + +header 2 +-------- + +test + +### header 3 + +test + +Execute (Toc setex headers): + :Toc + +Expect (setex headers): + header 1 + header 2 + header 3 + +Given markdown; +# header 1 + +test + +## header 2 + +test + +### header 3 + +test + +Execute (Toc atx headers): + :Toc + +Expect (atx headers): + header 1 + header 2 + header 3