Skip to content

Commit f1a9922

Browse files
author
skywind3000
committed
add try/catch to executing event script in listbox/context-menu
1 parent fef6764 commit f1a9922

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

autoload/quickui/context.vim

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" context.vim -
44
"
55
" Created by skywind on 2019/12/19
6-
" Last Modified: 2019/12/19 15:21:18
6+
" Last Modified: 2020/02/13 16:24
77
"
88
"======================================================================
99

@@ -286,7 +286,13 @@ function! s:popup_exit(winid, code)
286286
if item.is_sep == 0 && item.enable != 0
287287
if item.cmd != ''
288288
redraw
289-
exec item.cmd
289+
try
290+
exec item.cmd
291+
catch /.*/
292+
echohl Error
293+
echom v:exception
294+
echohl None
295+
endtry
290296
endif
291297
endif
292298
endif
@@ -630,7 +636,13 @@ function! s:nvim_create_context(textlist, opts)
630636
if item.is_sep == 0 && item.enable != 0
631637
if item.cmd != ''
632638
redraw
633-
exec item.cmd
639+
try
640+
exec item.cmd
641+
catch /.*/
642+
echohl Error
643+
echom v:exception
644+
echohl None
645+
endtry
634646
endif
635647
endif
636648
endif

autoload/quickui/listbox.vim

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" listbox.vim -
44
"
55
" Created by skywind on 2019/12/20
6-
" Last Modified: 2019/12/20 15:31:14
6+
" Last Modified: 2020/02/13 16:26
77
"
88
"======================================================================
99

@@ -267,7 +267,13 @@ function! s:popup_exit(winid, code)
267267
let cmd = hwnd.items.cmds[code]
268268
if cmd != ''
269269
redraw
270-
exec cmd
270+
try
271+
exec cmd
272+
catch /.*/
273+
echohl Error
274+
echom v:exception
275+
echohl None
276+
endtry
271277
endif
272278
endif
273279
endfunc
@@ -614,7 +620,13 @@ function! s:nvim_create_listbox(textlist, opts)
614620
if retval >= 0 && retval < hwnd.items.nrows
615621
let cmd = hwnd.items.cmds[retval]
616622
if cmd != ''
617-
exec cmd
623+
try
624+
exec cmd
625+
catch /.*/
626+
echohl Error
627+
echom v:exception
628+
echohl None
629+
endtry
618630
endif
619631
endif
620632
return retval

autoload/quickui/tags.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ function! quickui#tags#ctags_function(bid, ft)
320320
call writefile(content, srcname)
321321
unlet content
322322
endif
323+
if exists('g:quickui_tags_list')
324+
let extras = get(g:quickui_tags_list, ft, extras)
325+
endif
323326
let cmd = ctags . ' -n -u --fields=k ' . extras . ' -f- '
324327
let output = quickui#utils#system(cmd . '"' . srcname . '"')
325328
if modified

autoload/quickui/tools.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,14 @@ function! quickui#tools#list_function()
150150
let maxsize = (&columns) * 60 / 100
151151
let maxheight = (&lines) * 60 / 100
152152
let maxwidth = 0
153+
let indents = get(g:, 'quickui_tags_indent', {})
153154
for item in items
154155
if ln >= item.line
155156
let cursor = index
156157
endif
157158
let index += 1
158-
let text = '' . item.mode . '' . " \t" . item.text
159+
let space = get(indents, item.mode, '')
160+
let text = '' . item.mode . '' . " \t" . space . item.text
159161
let text = text . ' [:' . item.line . ']'
160162
let maxwidth = (maxwidth < len(text))? len(text) : maxwidth
161163
let text = substitute(text, '&', '&&', 'g')

0 commit comments

Comments
 (0)