From 21d86a45e166a877a9e79c3ca638efe754e37acf Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Wed, 27 Jan 2016 11:12:58 +0900 Subject: [PATCH] No indent hash header after list Fix #146 --- indent/markdown.vim | 7 +++++++ test/indent.vader | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/indent/markdown.vim b/indent/markdown.vim index 540bc04..faa7629 100755 --- a/indent/markdown.vim +++ b/indent/markdown.vim @@ -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 @@ -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 diff --git a/test/indent.vader b/test/indent.vader index aabf54f..baa2d34 100644 --- a/test/indent.vader +++ b/test/indent.vader @@ -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 -- 2.39.2