Skip to content

Commit 25777f2

Browse files
committed
Add some feedback to goto command
1 parent 5d27bf6 commit 25777f2

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

autoload/jsonpath.vim

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,36 +190,35 @@ function! jsonpath#goto(...) "{{{
190190
let search_for = get(a:, 1)
191191
if empty(search_for)
192192
let search_for = input('Path (using dot notation): ')
193+
if empty(search_for)
194+
echo 'Search aborted'
195+
return
196+
endif
193197
endif
194198

195-
echo 'Searching buffer...' | redraw
196-
197199
let pos = jsonpath#scan_buffer(search_for)
198200

199-
if !empty(pos)
200-
call setpos('.', pos)
201-
else
201+
if empty(pos)
202202
echo 'Path not found: ' . search_for
203+
else
204+
call setpos('.', pos)
205+
echo 'Found on line ' . pos[1]
203206
endif
204-
205-
return ''
206207
endfunction "}}}
207208

208209
" Echoes the path of the identifier under the cursor
209210
function! jsonpath#echo() "{{{
210211
echo 'Parsing buffer...' | redraw
211212
let path = jsonpath#scan_buffer([], line('.'), col('.'))
212213
echo len(path) ? 'Path: ' . join(path, g:jsonpath_delimeter) : 'Empty path'
213-
214-
return ''
215214
endfunction "}}}
216215

217216
" Entry point for the :JsonPath command
218217
function! jsonpath#command(input) "{{{
219218
if empty(a:input)
220-
return jsonpath#echo()
219+
jsonpath#echo()
221220
else
222-
return jsonpath#goto(a:input)
221+
jsonpath#goto(a:input)
223222
endif
224223
endfunction "}}}
225224

0 commit comments

Comments
 (0)