Skip to content

Commit 08b9747

Browse files
committed
Add lots of debug logging (related to issue #53)
1 parent 9b7eb4e commit 08b9747

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

autoload/xolox/notes.vim

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
" Note: This file is encoded in UTF-8 including a byte order mark so
77
" that Vim loads the script using the right encoding transparently.
88

9-
let g:xolox#notes#version = '0.33.2'
9+
let g:xolox#notes#version = '0.33.3'
1010
let g:xolox#notes#url_pattern = '\<\(mailto:\|javascript:\|\w\{3,}://\)\(\S*\w\)\+/\?'
1111
let s:scriptdir = expand('<sfile>:p:h')
1212

@@ -482,12 +482,14 @@ function! xolox#notes#search(bang, input) " {{{1
482482
endif
483483
endif
484484
if input =~ '^/.\+/$'
485+
call xolox#misc#msg#debug("notes.vim %s: Performing pattern search (%s) ..", g:xolox#notes#version, input)
485486
call s:internal_search(a:bang, input, '', '')
486487
call s:set_quickfix_title([], input)
487488
else
488489
let keywords = split(input)
489490
let all_keywords = s:match_all_keywords(keywords)
490491
let any_keyword = s:match_any_keyword(keywords)
492+
call xolox#misc#msg#debug("notes.vim %s: Performing keyword search (%s) ..", g:xolox#notes#version, input)
491493
call s:internal_search(a:bang, all_keywords, input, any_keyword)
492494
if &buftype == 'quickfix'
493495
" Enable line wrapping in the quick-fix window.
@@ -696,10 +698,12 @@ function! s:internal_search(bang, pattern, keywords, phase2) " {{{2
696698
let notes = []
697699
let phase2_needed = 1
698700
if a:keywords != '' && s:run_scanner(a:keywords, notes)
701+
call xolox#misc#msg#debug("notes.vim %s: Skipping phase 1 search (performed using Python script) ..", g:xolox#notes#version)
699702
if a:phase2 != ''
700703
let pattern = a:phase2
701704
endif
702705
else
706+
call xolox#misc#msg#debug("notes.vim %s: Performing phase 1 search to gather matching notes ..", g:xolox#notes#version)
703707
call s:vimgrep_wrapper(a:bang, a:pattern, xolox#notes#get_fnames(0))
704708
let notes = s:qflist_to_filenames()
705709
if a:phase2 != ''
@@ -717,7 +721,12 @@ function! s:internal_search(bang, pattern, keywords, phase2) " {{{2
717721
" search using :vimgrep we need to run :vimgrep another time to get the
718722
" quick-fix list in the right format :-|
719723
if phase2_needed
724+
call setqflist([])
725+
call xolox#misc#msg#debug("notes.vim %s: Performing phase 2 search to populate quick-fix window ..", g:xolox#notes#version)
720726
call s:vimgrep_wrapper(a:bang, pattern, notes)
727+
if !empty(notes) && empty(getqflist())
728+
throw "Failed to populate quick-fix window! Looks like you're being bitten by this bug: https://github.com/xolox/vim-notes/issues/53"
729+
endif
721730
endif
722731
if a:bang == '' && bufnr('%') != bufnr_save
723732
" If :vimgrep opens the first matching file while &eventignore is still
@@ -737,8 +746,8 @@ function! s:vimgrep_wrapper(bang, pattern, files) " {{{2
737746
let args = map(copy(a:files), 'fnameescape(v:val)')
738747
call insert(args, a:pattern . 'j')
739748
let s:swaphack_enabled = 1
749+
let ei_save = &eventignore
740750
try
741-
let ei_save = &eventignore
742751
set eventignore=syntax,bufread
743752
let command = printf('vimgrep%s %s', a:bang, join(args))
744753
call xolox#misc#msg#debug("notes.vim %s: Populating quick-fix window using command: %s", g:xolox#notes#version, command)

0 commit comments

Comments
 (0)