@@ -33,12 +33,23 @@ function! s:set_db() abort
33
33
endfunction
34
34
35
35
36
+ function ! s: save_cwd () abort
37
+ let g: codequery_cwd = getcwd ()
38
+ endfunction
39
+
40
+
41
+ function ! s: restore_cwd () abort
42
+ execute ' lcd ' . g: codequery_cwd
43
+ endfunction
44
+
45
+
36
46
37
47
" =============================================================================
38
48
" Entries
39
49
40
50
41
51
function ! codequery#run_codequery (args ) abort
52
+ call s: save_cwd ()
42
53
if ! s: check_filetype (&filetype )
43
54
echom ' Not Supported Filetype: ' . &filetype
44
55
return
@@ -50,6 +61,7 @@ function! codequery#run_codequery(args) abort
50
61
let g: codequery_querytype = 1
51
62
let g: codequery_db_path = ' '
52
63
if ! s: set_db ()
64
+ call s: restore_cwd ()
53
65
return
54
66
endif
55
67
@@ -66,17 +78,20 @@ function! codequery#run_codequery(args) abort
66
78
let word = codequery#query#get_final_query_word (iword, cword)
67
79
if empty (word)
68
80
echom ' Invalid Args: ' . a: args
81
+ call s: restore_cwd ()
69
82
return
70
83
endif
71
84
72
85
call codequery#query#do_query (word)
73
86
else
74
87
echom ' Wrong Subcommand !'
75
88
endif
89
+ call s: restore_cwd ()
76
90
endfunction
77
91
78
92
79
93
function ! codequery#make_codequery_db (args ) abort
94
+ call s: save_cwd ()
80
95
let args = split (a: args , ' ' )
81
96
if empty (args )
82
97
let args = [&filetype ]
@@ -126,10 +141,12 @@ function! codequery#make_codequery_db(args) abort
126
141
endif
127
142
" ----------------------------------------------------------------
128
143
endfor
144
+ call s: restore_cwd ()
129
145
endfunction
130
146
131
147
132
148
function ! codequery#view_codequery_db (args ) abort
149
+ call s: save_cwd ()
133
150
let args = split (a: args , ' ' )
134
151
if empty (args )
135
152
let args = [&filetype ]
@@ -153,10 +170,12 @@ function! codequery#view_codequery_db(args) abort
153
170
154
171
execute ' !echo "\n(' . db_path . ' ) is update at: " && stat -f "\%Sm" ' . db_path
155
172
endfor
173
+ call s: restore_cwd ()
156
174
endfunction
157
175
158
176
159
177
function ! codequery#move_codequery_db_to_git_hidden_dir (args ) abort
178
+ call s: save_cwd ()
160
179
let args = split (a: args , ' ' )
161
180
if empty (args )
162
181
let args = [&filetype ]
@@ -180,6 +199,7 @@ function! codequery#move_codequery_db_to_git_hidden_dir(args) abort
180
199
echom ' Git Dir Not Found or (' . db_name . ' ) Not Found'
181
200
endif
182
201
endfor
202
+ call s: restore_cwd ()
183
203
endfunction
184
204
185
205
0 commit comments