Skip to content

Commit

Permalink
fixes #140 jumping to setex headers in mkdx#JumpToHeader is now suppo…
Browse files Browse the repository at this point in the history
…rted
  • Loading branch information
SidOfc committed Apr 7, 2021
1 parent b04a2ef commit 6d06c4c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions autoload/mkdx.vim
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ endfun
fun! s:util.JumpToHeader(link, hashes, jid, stream, ...)
if (s:util._header_found) | return | endif
let stream = type(a:stream) == s:LIST ? a:stream : [a:stream]
call filter(stream, {idx, line -> !empty(line)})

for line in stream
let item = s:util.IdentifyGrepLink(line)
let hash = item.type == 'anchor' ? item.content : s:util.transform(tolower(getline(item.lnum)), ['clean-header', 'header-to-hash'])
Expand All @@ -377,6 +379,23 @@ fun! s:util.JumpToHeader(link, hashes, jid, stream, ...)
break
endif
endfor

if (!s:util._header_found)
for lnum in range(2, line('$'))
let line = getline(lnum)
if (match(line, '^\(===\|---\)') !=# -1)
let line_hash = s:util.transform(tolower(getline(lnum - 1)), ['clean-header', 'header-to-hash'])
if (a:link ==# line_hash)
if (g:mkdx#settings.links.fragment.jumplist)
normal! m'0
endif
call cursor(lnum - 1, 0)
redraw
break
endif
endif
endfor
endif
endfun

fun! s:util.EchoQuickfixCount(subject, ...)
Expand Down

0 comments on commit 6d06c4c

Please sign in to comment.