Skip to content

Commit

Permalink
No indent hash header after list
Browse files Browse the repository at this point in the history
Fix #146
  • Loading branch information
shirosaki committed Jan 27, 2016
1 parent 8d3d113 commit 21d86a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions indent/markdown.vim
Expand Up @@ -28,6 +28,10 @@ function! s:IsLiStart(line)
\ a:line =~ '^\s*[*+-] \+'
endfunction

function! s:IsHeaderLine(line)
return a:line =~ '^\s*#'
endfunction

function! s:IsBlankLine(line)
return a:line =~ '^$'
endfunction
Expand Down Expand Up @@ -55,6 +59,9 @@ function GetMarkdownIndent()
if s:IsLiStart(cline)
" Current line is the first line of a list item, do not change indent
return indent(v:lnum)
elseif s:IsHeaderLine(cline) && !s:IsMkdCode(v:lnum)
" Current line is the header, do not indent
return 0
elseif s:IsLiStart(line)
if s:IsMkdCode(lnum)
return ind
Expand Down
13 changes: 13 additions & 0 deletions test/indent.vader
Expand Up @@ -48,3 +48,16 @@ Expect (no autoindent outside list):


ba

Given markdown;
- a

# b

Do (insert header after list):
jjwi#

Expect (no indent header after list):
- a

## b

0 comments on commit 21d86a4

Please sign in to comment.