Skip to content

Commit

Permalink
Fix: count ignored when looking up diary frequency
Browse files Browse the repository at this point in the history
When calling VimwikiMakeYesterdayDiary (or Tomorrow) the wiki_nr is
looked up by vimwiki#diary#diary_date_link without access to the passed
count, which would result in the creation of the file in the correct
place, but with the diary_frequency of another wiki. Modify
vimwiki#diary#diary_date_link to take a possible third argument as the
wiki_nr+1 and modify the commands to pass <count> as the third argument.

Fixes: #1365
  • Loading branch information
ferdinandyb authored and tinmarino committed Oct 16, 2023
1 parent 65575fb commit 5d86b62
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
8 changes: 6 additions & 2 deletions autoload/vimwiki/diary.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ endfunction

function! vimwiki#diary#diary_date_link(...) abort
" Return: <String> date

let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
if a:0 > 2
" user supply wiki number as 1 indexed, not 0 indexed
let wiki_nr = a:3 - 1
else
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
endif
if wiki_nr < 0 " this happens when called outside a wiki buffer
let wiki_nr = 0
endif
Expand Down
10 changes: 7 additions & 3 deletions doc/vimwiki.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4005,6 +4005,7 @@ Contributors and their Github usernames in roughly chronological order:
- Julian Prein (@druckdev)
- Luke Atkinson (@LukeDAtkinson)
- Joe Planisky (@jplanisky)
- Bence Ferdinandy (@ferdinandyb)


==============================================================================
Expand All @@ -4025,8 +4026,11 @@ This is somewhat experimental, and will probably be refined over time.

New:~
* Issue #1279: Fix/Improvement: When re-wrap a long line in a definition
by 'gq' it should insert ':: ' at the new line

by 'gq' it should insert ':: ' at the new line

Fixed:~
* Issue #1365: Fix: count ignored when looking up diary frequency


2023.04.04~

Expand All @@ -4036,7 +4040,7 @@ Fixed:~
* PR #1324: Fix pressing escape in VimwikiGoto prompt (rddunphy)
* Issue #1336: vimwiki#diary#calendar_sign throws an error
when g:vimwiki_list is not set

2023.04.04~

New:~
Expand Down
8 changes: 4 additions & 4 deletions plugin/vimwiki.vim
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@ command! -count=0 VimwikiTabMakeDiaryNote

command! -count=0 VimwikiMakeYesterdayDiaryNote
\ call vimwiki#diary#make_note(<count>, 0,
\ vimwiki#diary#diary_date_link(localtime(), -1))
\ vimwiki#diary#diary_date_link(localtime(), -1, <count>))

command! -count=0 VimwikiMakeTomorrowDiaryNote
\ call vimwiki#diary#make_note(<count>, 0,
\ vimwiki#diary#diary_date_link(localtime(), 1))
\ vimwiki#diary#diary_date_link(localtime(), 1, <count>))

command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section()
Expand Down Expand Up @@ -399,10 +399,10 @@ nnoremap <silent><script> <Plug>VimwikiTabMakeDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 1)<CR>
nnoremap <silent><script> <Plug>VimwikiMakeYesterdayDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 0,
\ vimwiki#diary#diary_date_link(localtime(), -1))<CR>
\ vimwiki#diary#diary_date_link(localtime(), -1, v:count))<CR>
nnoremap <silent><script> <Plug>VimwikiMakeTomorrowDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 0,
\ vimwiki#diary#diary_date_link(localtime(), 1))<CR>
\ vimwiki#diary#diary_date_link(localtime(), 1, v:count))<CR>

" Set default global key mappings
Expand Down

0 comments on commit 5d86b62

Please sign in to comment.