2020-07-30 05:29:03 +02:00
|
|
|
# VimwikiRenameFile
|
|
|
|
# Related to link, file navigation
|
2020-08-05 06:39:00 +02:00
|
|
|
# Many commands are made with Do: They block with Execute
|
2020-01-05 05:21:52 +01:00
|
|
|
|
|
|
|
|
2020-07-29 06:37:44 +02:00
|
|
|
# Create directories I remove at end {{{1
|
|
|
|
##########################################
|
|
|
|
|
2020-01-05 05:21:52 +01:00
|
|
|
Execute (Copy Wiki's Resources):
|
|
|
|
Log "Start: Copy Resources"
|
|
|
|
call CopyResources()
|
|
|
|
|
|
|
|
|
|
|
|
Execute (Mkdir dir1 dir2 dir11 dir12):
|
|
|
|
call system("mkdir $HOME/testmarkdown/dir1")
|
|
|
|
call system("mkdir $HOME/testmarkdown/dir1/dir11")
|
|
|
|
call system("mkdir $HOME/testmarkdown/dir1/dir12")
|
|
|
|
call system("mkdir $HOME/testmarkdown/dir2")
|
|
|
|
|
|
|
|
|
2020-07-29 06:37:44 +02:00
|
|
|
# Test Transdirectory and argument {{{1
|
|
|
|
# New feature #926
|
|
|
|
|
|
|
|
# Create smaller unit {{{2
|
|
|
|
|
|
|
|
# we stick all along with these 3 files,
|
|
|
|
# Follow them !
|
|
|
|
Execute (Create 3 files):
|
|
|
|
edit $HOME/testmarkdown/Test-Rename-zzz.md
|
|
|
|
call WriteMe()
|
|
|
|
edit $HOME/testmarkdown/dir1/dir11/Test-Rename.md
|
|
|
|
call WriteMe()
|
|
|
|
edit $HOME/testmarkdown/Test-Rename-Completion.md
|
|
|
|
call WriteMe()
|
|
|
|
|
2020-08-05 06:39:00 +02:00
|
|
|
|
|
|
|
Do (Testing Old buffer has been wiped out {{{2):
|
|
|
|
:edit $HOME/testmarkdown/Test-Rename-Completion.md\<Cr>
|
2020-08-09 22:13:53 +02:00
|
|
|
:Log 'Get current Buffer'\<Cr>
|
2020-08-05 06:39:00 +02:00
|
|
|
:let buf_old = bufnr('%')\<Cr>
|
2020-08-09 22:13:53 +02:00
|
|
|
:Log 'Is this wiki 2'\<Cr>
|
|
|
|
:AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')\<Cr>
|
|
|
|
:Log 'Delete for loosers'\<Cr>
|
|
|
|
:call DeleteFile('$HOME/testmarkdown/Test-Rename-new1.md')\<Cr>
|
|
|
|
:Log 'Rewrite ...'\<Cr>
|
|
|
|
:call WriteMe()\<Cr>
|
|
|
|
:Log 'Rename 1'\<Cr>
|
2020-08-05 06:39:00 +02:00
|
|
|
:VimwikiRenameFile Test-Rename-new1\<Cr>
|
2020-08-09 22:13:53 +02:00
|
|
|
:Log 'Assert 1'\<Cr>
|
2020-08-05 06:39:00 +02:00
|
|
|
:AssertEqual 'Test-Rename-new1', expand('%:t:r')\<Cr>
|
2020-08-09 22:13:53 +02:00
|
|
|
:Log 'Rename 2'\<Cr>
|
2020-08-05 06:39:00 +02:00
|
|
|
:VimwikiRenameFile Test-Rename-Completion\<Cr>
|
2020-08-09 22:13:53 +02:00
|
|
|
:Log 'Assert 2'\<Cr>
|
2020-08-05 06:39:00 +02:00
|
|
|
:AssertEqual expand('%'), $HOME . '/testmarkdown/Test-Rename-Completion.md'\<Cr>
|
|
|
|
|
2020-07-29 06:37:44 +02:00
|
|
|
Do (Testing Completion {{{2):
|
|
|
|
# Rename and test (zzz)
|
|
|
|
:VimwikiRenameFile Test-Rename-z\<C-l>1\<Cr>
|
|
|
|
:AssertEqual $HOME . '/testmarkdown/Test-Rename-zzz1.md', expand('%')\<CR>\<Esc>
|
|
|
|
# Restore old name
|
|
|
|
:call WriteMe()\<Cr>
|
|
|
|
:VimwikiRenameFile Test-Rename-zzz\<Cr>
|
|
|
|
|
|
|
|
|
|
|
|
Do (Testing transforward {{{2):
|
|
|
|
:Log 'Forward: root -> dir1/dir11 {{{3'\<Cr>
|
|
|
|
# Create dir1/dir11/Test-Rename and link to it
|
|
|
|
:edit $HOME/testmarkdown/Test-Rename-Completion.md\<Cr>
|
2020-08-05 06:39:00 +02:00
|
|
|
ggdG
|
2020-07-29 06:37:44 +02:00
|
|
|
idir1/dir11/Test-Rename.md\<Esc>
|
|
|
|
\<Cr>\<Cr>
|
|
|
|
:VimwikiRenameFile ../Test-Rename-2\<Cr>
|
|
|
|
:AssertEqual expand('%'), $HOME . '/testmarkdown/dir1/Test-Rename-2.md'\<CR>\<Esc>
|
|
|
|
|
|
|
|
# See what happend in root
|
|
|
|
:call WriteMe()\<Cr>
|
|
|
|
:edit $HOME/testmarkdown/Test-Rename-Completion.md\<Cr>
|
|
|
|
:AssertEqual getline(1), '[dir1 dir11 Test Rename](dir1/Test-Rename-2.md)'\<Cr>
|
|
|
|
|
|
|
|
:Log 'Backward dir1/dir11 -> root {{{3'\<Cr>
|
|
|
|
# See what happend in dir1/dir11
|
|
|
|
# I am in root so pressing Enter sends me to dir1/dir11
|
|
|
|
\<Cr>
|
|
|
|
# Write forward path
|
|
|
|
dd
|
|
|
|
i../Test-Rename-Completion\<Esc>
|
|
|
|
# Convert it to link
|
|
|
|
0\<Cr>\<Cr>
|
|
|
|
|
|
|
|
# Now in root
|
|
|
|
:AssertEqual expand('%'), $HOME . '/testmarkdown/Test-Rename-Completion.md'\<Cr>
|
|
|
|
:VimwikiRenameFile dir1/Test-Rename-Completion-2\<Cr>
|
|
|
|
:AssertEqual expand('%'), $HOME . '/testmarkdown/dir1/Test-Rename-Completion-2.md'\<Cr>
|
|
|
|
|
|
|
|
|
2020-08-05 06:39:00 +02:00
|
|
|
Execute (Delete smaller unit changed {{{2):
|
2020-08-09 22:13:53 +02:00
|
|
|
call DeleteFile('$HOME/testmarkdown/Test-Rename-new1.md')
|
2020-07-29 06:37:44 +02:00
|
|
|
call DeleteFile('$HOME/testmarkdown/Test-Rename-zzz.md')
|
|
|
|
call DeleteFile('$HOME/testmarkdown/dir1/Test-Rename-Completion_2.md')
|
|
|
|
call DeleteFile('$HOME/testmarkdown/dir1/Test-Rename-2.md')
|
|
|
|
|
|
|
|
|
|
|
|
# VimwikiRename Test same directory {{{1
|
|
|
|
# Old big conf, from bad unit test design
|
|
|
|
# Changing file in a single dir
|
|
|
|
# Feel free to modify but as long as it works
|
|
|
|
# I delay the cleaning
|
|
|
|
####################################
|
|
|
|
|
2020-01-05 05:21:52 +01:00
|
|
|
Given vimwiki (Void):
|
|
|
|
|
|
|
|
|
|
|
|
Execute (Create Test-Rename -> dir1/dir11/in_dir11.md and dir1/dir12/in_dir12.md and dir2/in_dir2.md):
|
|
|
|
edit $HOME/testmarkdown/Test-Rename.md
|
|
|
|
AssertEqual $HOME . '/testmarkdown/Test-Rename.md', expand('%')
|
|
|
|
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
|
|
|
|
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
|
|
|
|
call append(0, ['# Test Rename', 'in_root.md', 'dir1/dir11/in_dir11.md', 'dir1/dir12/in_dir12.md', 'dir2/in_dir2.md'])
|
|
|
|
call WriteMe()
|
|
|
|
|
|
|
|
Do (Create in_root):
|
|
|
|
:Log 'Open Test-Rename.md'\<CR>
|
|
|
|
:edit $HOME/testmarkdown/Test-Rename.md\<CR>
|
|
|
|
:AssertEqual $HOME . '/testmarkdown/Test-Rename.md', expand('%')\<CR>\<Esc>
|
|
|
|
|
|
|
|
:Log 'Delete last line (easyer latter checks without trailing spaces)'\<CR>
|
|
|
|
Gdd
|
|
|
|
|
|
|
|
:Log 'Open in_root.md'\<CR>
|
|
|
|
gg
|
|
|
|
j\<CR>
|
|
|
|
j\<CR>
|
|
|
|
j\<CR>
|
|
|
|
j\<CR>
|
|
|
|
ggj0y$
|
|
|
|
:AssertEqual '[in_root](in_root.md)', @"\<CR>
|
|
|
|
0\<CR>
|
|
|
|
:AssertEqual $HOME . '/testmarkdown/in_root.md', expand('%')\<CR>
|
|
|
|
|
|
|
|
:Log 'Add link in_root.md -> dir1/dir11/in_dir11'\<CR>
|
|
|
|
ggi# Title in root\<CR>\<Esc>
|
|
|
|
idir1/dir11/in_dir11\<Esc>
|
|
|
|
:call WriteMe()\<CR>
|
|
|
|
:AssertEqual $HOME . '/testmarkdown/in_root.md', expand('%')\<CR>
|
|
|
|
|
|
|
|
:Log 'Open in_dir11.md: creating dirs'\<CR>
|
|
|
|
ggj"ay$
|
|
|
|
:AssertEqual 'reg dir1/dir11/in_dir11', 'reg ' . @a\<CR>
|
|
|
|
0\<CR>\<CR>
|
|
|
|
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11.md', 'file ' . expand('%')\<CR>
|
|
|
|
|
|
|
|
:Log 'One backspace for fun'\<CR>
|
|
|
|
\<BS>
|
|
|
|
:AssertEqual 'file ' . $HOME . '/testmarkdown/in_root.md', 'file ' . expand('%')\<CR>
|
|
|
|
|
|
|
|
|
|
|
|
Do (Create dir_11 -> dir_11):
|
|
|
|
:edit $HOME/testmarkdown/dir1/dir11/in_dir11_fix.md\<CR>
|
|
|
|
|
|
|
|
:Log 'Add link in_dir11_fix.md -> in_dir11'\<CR>
|
|
|
|
ggi# Title in dir11 fix\<CR>\<Esc>
|
|
|
|
iin_dir11\<Esc>
|
|
|
|
:call WriteMe()\<CR>
|
|
|
|
|
|
|
|
:Log 'Open in_dir11.md: creating dirs'\<CR>
|
|
|
|
ggj"ay$
|
|
|
|
:AssertEqual 'reg in_dir11', 'reg ' . @a\<CR>
|
|
|
|
0\<CR>\<CR>
|
|
|
|
y\<CR>
|
|
|
|
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11.md', 'file ' . expand('%')\<CR>
|
|
|
|
|
|
|
|
:Log 'One backspace for fun'\<CR>
|
|
|
|
\<BS>
|
|
|
|
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11_fix.md', 'file ' . expand('%')\<CR>
|
|
|
|
|
|
|
|
|
|
|
|
Execute (Fill in_dir11 content):
|
|
|
|
edit $HOME/testmarkdown/dir1/dir11/in_dir11.md
|
|
|
|
call append(0, ['# Title in_dir11', '[dir2 link](../../dir2/in_dir2.md)'])
|
|
|
|
call WriteMe()
|
|
|
|
|
|
|
|
|
2020-07-29 06:37:44 +02:00
|
|
|
# Rename local {{{1
|
|
|
|
###################
|
|
|
|
|
|
|
|
Do (RenameLink in_dir11 -> in_dir11_new):
|
2020-01-05 05:21:52 +01:00
|
|
|
:edit $HOME/testmarkdown/dir1/dir11/in_dir11.md\<CR>
|
|
|
|
:AssertEqual 'file ' . $HOME . '/testmarkdown/dir1/dir11/in_dir11.md', 'file ' . expand('%')\<CR>
|
|
|
|
:AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')\<CR>
|
|
|
|
|
|
|
|
:Log 'Rename'\<CR>
|
|
|
|
:call WriteMe()\<CR>
|
2020-05-24 23:49:28 +02:00
|
|
|
:VimwikiRenameFile\<CR>
|
2020-01-05 05:21:52 +01:00
|
|
|
y\<CR>
|
|
|
|
in_dir11_new\<CR>
|
|
|
|
:call WriteMe()\<Cr>
|
|
|
|
|
|
|
|
:Log 'Append filename'\<CR>
|
|
|
|
:call append('$', [expand('%')])\<CR>
|
|
|
|
|
|
|
|
|
|
|
|
Expect(With new filename at the end):
|
|
|
|
# Title in_dir11
|
|
|
|
[dir2 link](../../dir2/in_dir2.md)
|
|
|
|
|
|
|
|
/home/vimtest/testmarkdown/dir1/dir11/in_dir11_new.md
|
|
|
|
|
|
|
|
|
|
|
|
Execute (edit in_dir11_fix):
|
|
|
|
edit $HOME/testmarkdown/dir1/dir11/in_dir11_fix.md
|
|
|
|
|
|
|
|
Expect(Link to in_dir11_new):
|
|
|
|
# Title in dir11 fix
|
|
|
|
[in_dir11](in_dir11_new)
|
|
|
|
|
|
|
|
|
|
|
|
Execute (edit Test-Rename.md):
|
|
|
|
edit $HOME/testmarkdown/Test-Rename.md
|
|
|
|
|
|
|
|
|
|
|
|
Expect (Link to in_dir11_new):
|
|
|
|
# Test Rename
|
|
|
|
[in_root](in_root.md)
|
|
|
|
[dir1 dir11 in_dir11](dir1/dir11/in_dir11_new.md)
|
|
|
|
[dir1 dir12 in_dir12](dir1/dir12/in_dir12.md)
|
|
|
|
[dir2 in_dir2](dir2/in_dir2.md)
|
|
|
|
|
|
|
|
|
|
|
|
Do (in_dir2 -> in_dir2_new):
|
|
|
|
:edit $HOME/testmarkdown/dir2/in_dir2.md\<CR>
|
|
|
|
|
|
|
|
:Log 'Append filename'\<CR>
|
|
|
|
:call append('$', [expand('%')])\<CR>
|
|
|
|
|
|
|
|
:Log 'Rename'\<CR>
|
|
|
|
:call WriteMe()\<CR>
|
2020-05-24 23:49:28 +02:00
|
|
|
:VimwikiRenameFile\<CR>
|
2020-01-05 05:21:52 +01:00
|
|
|
y\<CR>
|
|
|
|
in_dir2_new\<CR>
|
|
|
|
:call WriteMe()\<Cr>
|
|
|
|
|
|
|
|
:Log 'Append filename'\<CR>
|
|
|
|
:call append('$', [expand('%')])\<CR>
|
|
|
|
|
|
|
|
|
|
|
|
Expect (old and new filenames):
|
2020-07-25 09:40:50 +02:00
|
|
|
|
2020-01-05 05:21:52 +01:00
|
|
|
/home/vimtest/testmarkdown/dir2/in_dir2.md
|
|
|
|
/home/vimtest/testmarkdown/dir2/in_dir2_new.md
|
|
|
|
|
|
|
|
Execute (edit Test-Rename.md):
|
|
|
|
edit $HOME/testmarkdown/Test-Rename.md
|
|
|
|
|
|
|
|
|
|
|
|
Expect (Link to in_dir11_new):
|
|
|
|
# Test Rename
|
|
|
|
[in_root](in_root.md)
|
|
|
|
[dir1 dir11 in_dir11](dir1/dir11/in_dir11_new.md)
|
|
|
|
[dir1 dir12 in_dir12](dir1/dir12/in_dir12.md)
|
|
|
|
[dir2 in_dir2](dir2/in_dir2_new.md)
|
|
|
|
|
|
|
|
|
|
|
|
Execute (edit in_dir11.md):
|
|
|
|
edit $HOME/testmarkdown/dir1/dir11/in_dir11_new.md
|
|
|
|
|
|
|
|
|
|
|
|
Expect (Link to in_dir2_new):
|
|
|
|
# Title in_dir11
|
|
|
|
[dir2 link](../../dir2/in_dir2_new.md)
|
|
|
|
|
|
|
|
/home/vimtest/testmarkdown/dir1/dir11/in_dir11_new.md
|
|
|
|
|
|
|
|
|
|
|
|
Execute (Clean dir1 and dir2):
|
|
|
|
Log "End: Clean"
|
|
|
|
call DeleteHiddenBuffers()
|
|
|
|
call system('rm $HOME/testmarkdown/Test-Rename.md')
|
|
|
|
call system('rm $HOME/testmarkdown/in_root.md')
|
|
|
|
call system('rm -r $HOME/testmarkdown/dir1')
|
|
|
|
call system('rm -r $HOME/testmarkdown/dir2')
|
|
|
|
|
|
|
|
|
2020-07-29 06:37:44 +02:00
|
|
|
# vim: sw=2 foldmethod=marker foldlevel=30 foldignore=#
|