Skip to content

Commit

Permalink
test: add test of extract-header feature
Browse files Browse the repository at this point in the history
refer: #280
  • Loading branch information
lervag committed May 18, 2023
1 parent 4b7e7cb commit 9dafde4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions autoload/wiki/link.vim
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ function! wiki#link#set_text_from_header(range, line1, line2) abort "{{{1
if empty(l:title) | return | endif

try
let l:new = wiki#link#templates#{l:link.type}(l:link.url, l:title, l:link)
let l:new = wiki#link#templates#{l:link.type}(l:link.url_raw, l:title, l:link)
catch /E117:/
let l:new = wiki#link#templates#wiki(l:link.url, l:title)
let l:new = wiki#link#templates#wiki(l:link.url_raw, l:title)
endtry

call l:link.replace(l:new)
Expand Down
15 changes: 15 additions & 0 deletions test/test-links/test-extract.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
source ../init.vim

runtime plugin/wiki.vim

" Test transform normal on regular markdown links using wiki style links
silent edit ../wiki-basic/index.wiki
7WikiLinkExtractHeader
call assert_equal('[[NewPage|This page is new]]', getline(7))

silent edit!
execute "normal ggV10j\<plug>(wiki-link-extract-header)"
call assert_equal('[[NewPage|This page is new]]', getline(7))
call assert_equal('[[/sub/Foo|Foo]]', getline(9))

call wiki#test#finished()

0 comments on commit 9dafde4

Please sign in to comment.