Skip to content

Commit 8286279

Browse files
authored
Merge pull request #216 from dyng/feature/add-search-status
Add dynamic searching status
2 parents c6ae525 + 2a00698 commit 8286279

26 files changed

+111
-65
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ A demo shows how to rename a method named `MoveCursor()` to `Cursor()` in multip
3535

3636
- Search and display result in a user-friendly view with adjustable context.
3737

38-
- Works in both asynchronous (for Vim 8.0+) and synchronous (for older version of Vim) manner.
38+
- Works in both asynchronous (for Vim 8.0.1039+) and synchronous (for older version of Vim) manner.
3939

40-
- Edit mode which is incredible useful when you are doing project-wide refactoring. (Inspired by [vim-ags][6])
40+
- Edit mode which is incredible useful when you are working on project-wide refactoring. (Inspired by [vim-ags][6])
4141

4242
- Preview mode for fast exploring.
4343

44-
- Two types of views. For both users who like a sublime-like, rich context result window, or who feel more comfortable with good old quickfix window. (similar to ack.vim)
44+
- Two types of views. For both users who love a sublime-like, rich context result window, and users who feel more comfortable with good old quickfix window. (similar to ack.vim)
4545

46-
- Various options for customized search, view and edit.
46+
- Various options for customized search, view and edition.
4747

4848
## Installation
4949

after/plugin/ctrlsf.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: An ack/ag/pt/rg powered code search and view tool.
33
" Author: Ye Ding <dygvirus@gmail.com>
44
" Licence: Vim licence
5-
" Version: 2.0.0
5+
" Version: 2.0.2
66
" ============================================================================
77

88
" Loading Guard {{{1

autoload/ctrlsf.vim

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: An ack/ag/pt/rg powered code search and view tool.
33
" Author: Ye Ding <dygvirus@gmail.com>
44
" Licence: Vim licence
5-
" Version: 2.0.0
5+
" Version: 2.0.2
66
" ============================================================================
77

88
"""""""""""""""""""""""""""""""""
@@ -114,9 +114,16 @@ func! ctrlsf#SelfCheck() abort
114114
return -2
115115
endif
116116

117-
if g:ctrlsf_search_mode ==# 'async' && v:version < 800
118-
call ctrlsf#log#Error('Asynchronous searching is only supported on vim
119-
\ with version above 8.0. Your version: %s', v:version)
117+
if g:ctrlsf_search_mode ==# 'async' &&
118+
\ (v:version < 800 || (v:version == 800 && !has('patch1039')))
119+
call ctrlsf#log#Error('Asynchronous searching is only supported for Vim
120+
\ with version above 8.0.1039. Please update your vim.')
121+
return -3
122+
endif
123+
124+
if has('nvim')
125+
call ctrlsf#log#Error('Asynchronous searching is not supported for
126+
\ NeoVim yet.')
120127
return -3
121128
endif
122129
endf

autoload/ctrlsf/async.vim

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: An ack/ag/pt/rg powered code search and view tool.
33
" Author: Ye Ding <dygvirus@gmail.com>
44
" Licence: Vim licence
5-
" Version: 2.0.0
5+
" Version: 2.0.2
66
" ============================================================================
77

88
let s:job_id = -1
@@ -16,13 +16,19 @@ let s:consumed = 0
1616
" IsSearching()
1717
"
1818
func! ctrlsf#async#IsSearching() abort
19-
return s:done == 0
19+
return !ctrlsf#async#IsSearchDone()
2020
endf
2121

2222
" IsSearchDone()
2323
"
2424
func! ctrlsf#async#IsSearchDone() abort
25-
return s:done == 1
25+
return s:done == 1 && s:IsAllConsumed()
26+
endf
27+
28+
" IsCancelled()
29+
"
30+
func! ctrlsf#async#IsCancelled() abort
31+
return s:cancelled
2632
endf
2733

2834
" Reset()
@@ -37,24 +43,24 @@ func! ctrlsf#async#Reset() abort
3743
let s:consumed = 0
3844
endf
3945

40-
" IsAllConsumed()
46+
" s:IsAllConsumed()
4147
"
42-
func! ctrlsf#async#IsAllConsumed() abort
48+
func! s:IsAllConsumed() abort
4349
return s:consumed >= len(s:buffer)
4450
endf
4551

46-
" DiscardResult()
52+
" s:DiscardResult()
4753
"
48-
func! ctrlsf#async#DiscardResult() abort
54+
func! s:DiscardResult() abort
4955
let s:consumed = len(s:buffer)
5056
return
5157
endf
5258

53-
" ConsumeResult()
59+
" s:ConsumeResult()
5460
"
5561
" Consume at most {max} lines from result buffer.
5662
"
57-
func! ctrlsf#async#ConsumeResult(max) abort
63+
func! s:ConsumeResult(max) abort
5864
if s:consumed < len(s:buffer)
5965
let start = s:consumed
6066
let end = s:consumed + a:max
@@ -97,7 +103,7 @@ func! ctrlsf#async#StopSearch() abort
97103
if type(s:job_id) != type(-1)
98104
let stopped = job_stop(s:job_id, "int")
99105
if stopped
100-
call ctrlsf#async#DiscardResult()
106+
call s:DiscardResult()
101107
let s:cancelled = 1
102108
let s:done = 1
103109
else
@@ -109,10 +115,10 @@ endf
109115
" ParseAndDrawCB()
110116
"
111117
func! ctrlsf#async#ParseAndDrawCB(timer_id) abort
112-
let lines = ctrlsf#async#ConsumeResult(g:ctrlsf_parse_speed)
118+
let lines = s:ConsumeResult(g:ctrlsf_parse_speed)
113119
call ctrlsf#log#Debug("ConsumeResult: size=%s", len(lines))
114120

115-
let done = ctrlsf#async#IsSearchDone() && ctrlsf#async#IsAllConsumed()
121+
let done = ctrlsf#async#IsSearchDone() && s:IsAllConsumed()
116122

117123
call ctrlsf#db#ParseBackendResultIncr(lines, done)
118124
call ctrlsf#win#DrawIncr()
@@ -121,7 +127,7 @@ func! ctrlsf#async#ParseAndDrawCB(timer_id) abort
121127
call ctrlsf#async#StopParse()
122128
call ctrlsf#profile#Sample("FinishParse")
123129
call ctrlsf#win#SetModifiableByViewMode(1)
124-
if !s:cancelled
130+
if !ctrlsf#async#IsCancelled()
125131
call ctrlsf#log#Notice("Done!")
126132
endif
127133
call ctrlsf#log#Debug("ParseFinish")

autoload/ctrlsf/backend.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: An ack/ag/pt/rg powered code search and view tool.
33
" Author: Ye Ding <dygvirus@gmail.com>
44
" Licence: Vim licence
5-
" Version: 2.0.0
5+
" Version: 2.0.2
66
" ============================================================================
77

88
" Log file that collects error messages from backend
@@ -284,5 +284,5 @@ func! ctrlsf#backend#RunAsync(args) abort
284284
call ctrlsf#log#Debug("ExecCommand: %s", command)
285285

286286
call ctrlsf#async#StartSearch(command)
287-
call ctrlsf#log#Notice("Start searching...")
287+
call ctrlsf#log#Notice("Searching...")
288288
endf

autoload/ctrlsf/buf.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: An ack/ag/pt/rg powered code search and view tool.
33
" Author: Ye Ding <dygvirus@gmail.com>
44
" Licence: Vim licence
5-
" Version: 2.0.0
5+
" Version: 2.0.2
66
" ============================================================================
77

88
" WriteString()

autoload/ctrlsf/class/line.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: An ack/ag/pt/rg powered code search and view tool.
33
" Author: Ye Ding <dygvirus@gmail.com>
44
" Licence: Vim licence
5-
" Version: 2.0.0
5+
" Version: 2.0.2
66
" ============================================================================
77

88
" New()

autoload/ctrlsf/class/match.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: An ack/ag/pt/rg powered code search and view tool.
33
" Author: Ye Ding <dygvirus@gmail.com>
44
" Licence: Vim licence
5-
" Version: 2.0.0
5+
" Version: 2.0.2
66
" ============================================================================
77

88
" New()

autoload/ctrlsf/class/paragraph.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: An ack/ag/pt/rg powered code search and view tool.
33
" Author: Ye Ding <dygvirus@gmail.com>
44
" Licence: Vim licence
5-
" Version: 2.0.0
5+
" Version: 2.0.2
66
" ============================================================================
77

88
" New()

autoload/ctrlsf/comp.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: An ack/ag/pt/rg powered code search and view tool.
33
" Author: Ye Ding <dygvirus@gmail.com>
44
" Licence: Vim licence
5-
" Version: 2.0.0
5+
" Version: 2.0.2
66
" ============================================================================
77

88
" Completion()

0 commit comments

Comments
 (0)