Skip to content

Commit e7ceb53

Browse files
committed
vitalizer: Liberate from 'redir'
'redir' cannnot be nested and cannot be used in execute() function. The main reason why vital.vim used 'redir' has solved on Vim 8.0.1425 and vital.vim now supports Vim 8.1 or later thus we can use execute() instead.
1 parent 336d8ab commit e7ceb53

1 file changed

Lines changed: 3 additions & 23 deletions

File tree

autoload/vital/vital.vim

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,7 @@ function! s:_format_throwpoint(throwpoint) abort
186186
endfunction
187187

188188
function! s:_get_file_by_func_name(name) abort
189-
try
190-
redir => body
191-
silent execute 'verbose function' a:name
192-
finally
193-
redir END
194-
endtry
189+
let body = execute(printf('verbose function %s', a:name))
195190
let lines = split(body, "\n")
196191
let signature = matchstr(lines[0], '^\s*\zs.*')
197192
let file = matchstr(lines[1], '^\t\%(Last set from\|.\{-}:\)\s*\zs.*$')
@@ -265,7 +260,7 @@ function! s:_sid(path, filter_pattern) abort
265260
if has_key(s:cache_sid, unified_path)
266261
return s:cache_sid[unified_path]
267262
endif
268-
for line in filter(split(s:_execute(':scriptnames'), "\n"), 'v:val =~# a:filter_pattern')
263+
for line in filter(split(execute(':scriptnames'), "\n"), 'v:val =~# a:filter_pattern')
269264
let [_, sid, path; __] = matchlist(line, '^\s*\(\d\+\):\s\+\(.\+\)\s*$')
270265
if s:_unify_path(path) is# unified_path
271266
let s:cache_sid[unified_path] = sid
@@ -275,21 +270,6 @@ function! s:_sid(path, filter_pattern) abort
275270
return 0
276271
endfunction
277272

278-
" We want to use an execute() builtin function instead of s:_execute(),
279-
" however there is a bug in execute().
280-
" execute() returns empty string when it is called in
281-
" completion function of user defined ex command.
282-
" https://github.com/vim-jp/issues/issues/1129
283-
function! s:_execute(cmd) abort
284-
let [save_verbose, save_verbosefile] = [&verbose, &verbosefile]
285-
set verbose=0 verbosefile=
286-
redir => res
287-
silent! execute a:cmd
288-
redir END
289-
let [&verbose, &verbosefile] = [save_verbose, save_verbosefile]
290-
return res
291-
endfunction
292-
293273
if filereadable(expand('<sfile>:r') . '.VIM') " is case-insensitive or not
294274
let s:_unify_path_cache = {}
295275
" resolve() is slow, so we cache results.
@@ -314,7 +294,7 @@ endif
314294
" copied and modified from Vim.ScriptLocal
315295
let s:SNR = join(map(range(len("\<SNR>")), '"[\\x" . printf("%0x", char2nr("\<SNR>"[v:val])) . "]"'), '')
316296
function! s:sid2sfuncs(sid) abort
317-
let fs = split(s:_execute(printf(':function /^%s%s_', s:SNR, a:sid)), "\n")
297+
let fs = split(execute(printf(':function /^%s%s_', s:SNR, a:sid)), "\n")
318298
let r = {}
319299
let pattern = printf('\m^function\s<SNR>%d_\zs\w\{-}\ze(', a:sid)
320300
for fname in map(fs, 'matchstr(v:val, pattern)')

0 commit comments

Comments
 (0)