Skip to content

Error when opening calendar and wiki list is empty #290

@emilsenan

Description

@emilsenan
Error detected while processing function calendar#show[337]..vimwiki#diary#calendar_sign[6]..VimwikiGet:
line    3:
E684: list index out of range: 0
E116: Invalid arguments for function has_key(g:vimwiki_list[idx], a:option)
E15: Invalid expression: has_key(g:vimwiki_list[idx], a:option)

Steps to reproduce:

  1. install Calendar.vim (https://github.com/mattn/calendar-vim)
  2. let g:vimwiki_list = []
  3. open vim
  4. try to open calendar (:Calendar or cal)

Looks like that Calendar.vim hooks are always installed and hook methods don't check if any wiki actually exist. Hot and dirty fix for me at the moment:

--- vimwiki/autoload/vimwiki/diary.vim	2017-01-15 15:43:06.837918480 +0100
+++ vimwiki/autoload/vimwiki/diary.vim	2017-01-15 15:42:49.651220557 +0100
@@ -284,6 +284,9 @@
 
 " Sign function.
 function vimwiki#diary#calendar_sign(day, month, year) "{{{
+  if len(g:vimwiki_list) <= 0
+    return
+  endif
   let day = s:prefix_zero(a:day)
   let month = s:prefix_zero(a:month)
   let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path').

Metadata

Metadata

Assignees

No one assigned

    Labels

    3rd-partyIssues related to a 3rd party plugin or toolbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions