Fix: VimwikiTOC removes next non-empty line (Issue #910)
This commit is contained in:
parent
8a50d022b1
commit
0693e41132
@ -1468,8 +1468,8 @@ function! vimwiki#base#update_listing_in_buffer(Generator, start_header,
|
|||||||
|
|
||||||
" Set working range according to listing presence
|
" Set working range according to listing presence
|
||||||
if already_there
|
if already_there
|
||||||
let is_fold_closed = ( foldclosed(start_lnum) > -1 )
|
|
||||||
" Delete the old listing
|
" Delete the old listing
|
||||||
|
let is_fold_closed = ( foldclosed(start_lnum) > -1 )
|
||||||
let whitespaces_in_first_line = matchstr(getline(start_lnum), '\m^\s*')
|
let whitespaces_in_first_line = matchstr(getline(start_lnum), '\m^\s*')
|
||||||
let end_lnum = start_lnum + 1
|
let end_lnum = start_lnum + 1
|
||||||
while end_lnum <= line('$') && getline(end_lnum) =~# a:content_regex
|
while end_lnum <= line('$') && getline(end_lnum) =~# a:content_regex
|
||||||
@ -1486,6 +1486,7 @@ function! vimwiki#base#update_listing_in_buffer(Generator, start_header,
|
|||||||
let &l:foldenable = foldenable_save
|
let &l:foldenable = foldenable_save
|
||||||
let lines_diff = 0 - (end_lnum - start_lnum)
|
let lines_diff = 0 - (end_lnum - start_lnum)
|
||||||
else
|
else
|
||||||
|
" Create new listing
|
||||||
let start_lnum = a:default_lnum
|
let start_lnum = a:default_lnum
|
||||||
let is_cursor_after_listing = ( cursor_line > a:default_lnum )
|
let is_cursor_after_listing = ( cursor_line > a:default_lnum )
|
||||||
let whitespaces_in_first_line = ''
|
let whitespaces_in_first_line = ''
|
||||||
@ -1519,9 +1520,10 @@ function! vimwiki#base#update_listing_in_buffer(Generator, start_header,
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Remove empty line if end of file, otherwise append if needed
|
" Remove empty line if end of file, otherwise append if needed
|
||||||
if start_lnum == line('$')
|
let current_line = getline(start_lnum)
|
||||||
|
if start_lnum == line('$') && current_line =~# '^\s*$'
|
||||||
silent exe 'keepjumps ' . start_lnum.'delete _'
|
silent exe 'keepjumps ' . start_lnum.'delete _'
|
||||||
elseif start_lnum < line('$') && getline(start_lnum) !~# '\m^\s*$'
|
elseif start_lnum <= line('$') && current_line !~# '\m^\s*$'
|
||||||
keepjumps call append(start_lnum - 1, '')
|
keepjumps call append(start_lnum - 1, '')
|
||||||
let lines_diff += 1
|
let lines_diff += 1
|
||||||
endif
|
endif
|
||||||
@ -2491,8 +2493,7 @@ function! vimwiki#base#table_of_contents(create) abort
|
|||||||
return lines
|
return lines
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let links_rx = '\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)'
|
let links_rx = '\%(^\s*$\)\|\%(^\s*\%('.vimwiki#vars#get_syntaxlocal('rxListBullet').'\)\)'
|
||||||
|
|
||||||
call vimwiki#base#update_listing_in_buffer(
|
call vimwiki#base#update_listing_in_buffer(
|
||||||
\ GeneratorTOC,
|
\ GeneratorTOC,
|
||||||
\ toc_header_text,
|
\ toc_header_text,
|
||||||
|
@ -3743,6 +3743,7 @@ Changed:~
|
|||||||
Removed:~
|
Removed:~
|
||||||
|
|
||||||
Fixed:~
|
Fixed:~
|
||||||
|
* Issue #910: Fix: VimwikiTOC removes next non-empty line
|
||||||
* Issue #182: VimwikiTOC support headers with link
|
* Issue #182: VimwikiTOC support headers with link
|
||||||
* Issue #813: iMap <Cr> interfere with completion (pum)
|
* Issue #813: iMap <Cr> interfere with completion (pum)
|
||||||
* Issue #709: Support inline code spans inside emphasis
|
* Issue #709: Support inline code spans inside emphasis
|
||||||
|
@ -35,13 +35,15 @@ Execute (VimwikiGenerateLinks x 2):
|
|||||||
call append('$', 'Last Line')
|
call append('$', 'Last Line')
|
||||||
VimwikiGenerateLinks
|
VimwikiGenerateLinks
|
||||||
|
|
||||||
Expect (The links with a header):
|
Expect (The links with a header (bis)):
|
||||||
|
|
||||||
|
|
||||||
= Generated Links =
|
= Generated Links =
|
||||||
- [[buzz_bozz]]
|
- [[buzz_bozz]]
|
||||||
- [[index]]
|
- [[index]]
|
||||||
|
|
||||||
|
Last Line
|
||||||
|
|
||||||
Execute (Clean Test.wiki):
|
Execute (Clean Test.wiki):
|
||||||
call DeleteFile('$HOME/testwiki/Test.wiki')
|
call DeleteFile('$HOME/testwiki/Test.wiki')
|
||||||
|
|
||||||
|
@ -30,6 +30,37 @@
|
|||||||
#
|
#
|
||||||
# Start {{{1
|
# Start {{{1
|
||||||
|
|
||||||
|
Given vimwiki (One heading: May delete last line (#910) {{{1):
|
||||||
|
# Basic-title
|
||||||
|
|
||||||
|
|
||||||
|
Execute (VimwikiTOC x 1):
|
||||||
|
call SetSyntax('markdown')
|
||||||
|
set sw=8
|
||||||
|
VimwikiTOC
|
||||||
|
|
||||||
|
|
||||||
|
Expect(Good content with 1 item x 1):
|
||||||
|
# Contents
|
||||||
|
|
||||||
|
- [Basic-title](#basic-title)
|
||||||
|
|
||||||
|
# Basic-title
|
||||||
|
|
||||||
|
Execute (VimwikiTOC x 2):
|
||||||
|
call SetSyntax('markdown')
|
||||||
|
set sw=8
|
||||||
|
VimwikiTOC
|
||||||
|
VimwikiTOC
|
||||||
|
|
||||||
|
Expect(Good content with 1 item x 1):
|
||||||
|
# Contents
|
||||||
|
|
||||||
|
- [Basic-title](#basic-title)
|
||||||
|
|
||||||
|
# Basic-title
|
||||||
|
|
||||||
|
|
||||||
Given vimwiki (With link header (#182) {{{1):
|
Given vimwiki (With link header (#182) {{{1):
|
||||||
# A [link](anything here) B
|
# A [link](anything here) B
|
||||||
# t[link](anything here)
|
# t[link](anything here)
|
||||||
|
Loading…
Reference in New Issue
Block a user