Skip to content

Commit

Permalink
Setup a placeholder for 'FoldText()' function.
Browse files Browse the repository at this point in the history
  • Loading branch information
nelstrom committed Oct 24, 2012
1 parent a80b1b3 commit d800125
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
12 changes: 11 additions & 1 deletion after/ftplugin/markdown/folding.vim
@@ -1,4 +1,8 @@
" Helpers {{{1
function! s:SID()
return matchstr(expand('<sfile>'), '<SNR>\d\+_')
endfunction

function! HeadingDepth(lnum)
let level=0
let thisline = getline(a:lnum)
Expand All @@ -17,12 +21,18 @@ function! HeadingDepth(lnum)
endif
return level
endfunction

function! FoldText()
return 'placeholder'
endfunction

" Setup {{{1
setlocal foldmethod=expr
let &l:foldtext = s:SID() . 'FoldText()'
command! -buffer FoldToggle
" Teardown {{{1
let b:undo_ftplugin .= '
\ | setlocal foldmethod<
\ | setlocal foldmethod< foldtext<
\ | delcommand FoldToggle
\ '
" vim:set fdm=marker:
32 changes: 32 additions & 0 deletions test/folding.vim
Expand Up @@ -22,6 +22,10 @@ describe 'setting filetype=markdown'
Expect &l:foldmethod ==# 'expr'
end

it 'applies foldtext=FoldText()'
Expect &l:foldtext =~# '<SNR>\d_FoldText()'
end

it 'creates :FoldToggle command'
Expect exists(':FoldToggle') == 2
end
Expand All @@ -44,6 +48,11 @@ describe 'setting filetype!=markdown'
Expect &l:foldmethod ==# 'manual'
end

it 'resets foldtext to default'
setlocal filetype=
Expect &l:foldtext =~# 'foldtext()'
end

it 'destroys :FoldToggle command'
setlocal filetype=
Expect exists(':FoldToggle') == 0
Expand Down Expand Up @@ -130,3 +139,26 @@ describe 'HeadingDepth'
end

end

describe 'FoldText'

before
silent tabnew
setlocal filetype=markdown
end

after
silent tabclose!
end

" TODO: return to this after implementing foldexpr
" it 'uses "# level one" headings as is'
" call PopulateBuffer([
" \ '# Level one heading',
" \ '',
" \ 'Lorem ipsum dolor sit amet...',
" \ ])
" Expect foldtextresult('1') ==# '# Level one heading [2 lines]'
" end

end

0 comments on commit d800125

Please sign in to comment.