|
6 | 6 | " Note: This file is encoded in UTF-8 including a byte order mark so
|
7 | 7 | " that Vim loads the script using the right encoding transparently.
|
8 | 8 |
|
9 |
| -let g:xolox#notes#version = '0.23.3' |
| 9 | +let g:xolox#notes#version = '0.23.4' |
10 | 10 | let g:xolox#notes#url_pattern = '\<\(mailto:\|javascript:\|\w\{3,}://\)\(\S*\w\)\+/\?'
|
11 | 11 | let s:scriptdir = expand('<sfile>:p:h')
|
12 | 12 |
|
@@ -430,38 +430,42 @@ endfunction
|
430 | 430 |
|
431 | 431 | function! xolox#notes#search(bang, input) " {{{1
|
432 | 432 | " Search all notes for the pattern or keywords {input} (current word if none given).
|
433 |
| - let starttime = xolox#misc#timer#start() |
434 |
| - let input = a:input |
435 |
| - if input == '' |
436 |
| - let input = s:tag_under_cursor() |
| 433 | + try |
| 434 | + let starttime = xolox#misc#timer#start() |
| 435 | + let input = a:input |
437 | 436 | if input == ''
|
438 |
| - call xolox#misc#msg#warn("notes.vim %s: No string under cursor", g:xolox#notes#version) |
439 |
| - return |
| 437 | + let input = s:tag_under_cursor() |
| 438 | + if input == '' |
| 439 | + call xolox#misc#msg#warn("notes.vim %s: No string under cursor", g:xolox#notes#version) |
| 440 | + return |
| 441 | + endif |
440 | 442 | endif
|
441 |
| - endif |
442 |
| - if input =~ '^/.\+/$' |
443 |
| - call s:internal_search(a:bang, input, '', '') |
444 |
| - call s:set_quickfix_title([], input) |
445 |
| - else |
446 |
| - let keywords = split(input) |
447 |
| - let all_keywords = s:match_all_keywords(keywords) |
448 |
| - let any_keyword = s:match_any_keyword(keywords) |
449 |
| - call s:internal_search(a:bang, all_keywords, input, any_keyword) |
450 |
| - if &buftype == 'quickfix' |
451 |
| - " Enable line wrapping in the quick-fix window. |
452 |
| - setlocal wrap |
453 |
| - " Resize the quick-fix window to 1/3 of the screen height. |
454 |
| - let max_height = &lines / 3 |
455 |
| - execute 'resize' max_height |
456 |
| - " Make it smaller if the content doesn't fill the window. |
457 |
| - normal G$ |
458 |
| - let preferred_height = winline() |
459 |
| - execute 'resize' min([max_height, preferred_height]) |
460 |
| - normal gg |
461 |
| - call s:set_quickfix_title(keywords, '') |
| 443 | + if input =~ '^/.\+/$' |
| 444 | + call s:internal_search(a:bang, input, '', '') |
| 445 | + call s:set_quickfix_title([], input) |
| 446 | + else |
| 447 | + let keywords = split(input) |
| 448 | + let all_keywords = s:match_all_keywords(keywords) |
| 449 | + let any_keyword = s:match_any_keyword(keywords) |
| 450 | + call s:internal_search(a:bang, all_keywords, input, any_keyword) |
| 451 | + if &buftype == 'quickfix' |
| 452 | + " Enable line wrapping in the quick-fix window. |
| 453 | + setlocal wrap |
| 454 | + " Resize the quick-fix window to 1/3 of the screen height. |
| 455 | + let max_height = &lines / 3 |
| 456 | + execute 'resize' max_height |
| 457 | + " Make it smaller if the content doesn't fill the window. |
| 458 | + normal G$ |
| 459 | + let preferred_height = winline() |
| 460 | + execute 'resize' min([max_height, preferred_height]) |
| 461 | + normal gg |
| 462 | + call s:set_quickfix_title(keywords, '') |
| 463 | + endif |
462 | 464 | endif
|
463 |
| - endif |
464 |
| - call xolox#misc#timer#stop("notes.vim %s: Searched notes in %s.", g:xolox#notes#version, starttime) |
| 465 | + call xolox#misc#timer#stop("notes.vim %s: Searched notes in %s.", g:xolox#notes#version, starttime) |
| 466 | + catch /^Vim\%((\a\+)\)\=:E480/ |
| 467 | + call xolox#misc#msg#warn("notes.vim %s: No matches", g:xolox#notes#version) |
| 468 | + endtry |
465 | 469 | endfunction
|
466 | 470 |
|
467 | 471 | function! s:tag_under_cursor() " {{{2
|
|
0 commit comments