Avoid potential issues with nested :redir calls by preferring execute()
authorGreg Hurrell <greg@hurrell.net>
Mon, 18 Feb 2019 23:02:42 +0000 (00:02 +0100)
committerGreg Hurrell <greg@hurrell.net>
Mon, 18 Feb 2019 23:06:49 +0000 (00:06 +0100)
autoload/pinnacle.vim

index ae9db70cca83914f5e51da260023ff8310a4ead6..e552868027d6b060a451a54ec6b01a4bc4652020 100644 (file)
@@ -161,6 +161,10 @@ function! pinnacle#sub_newlines(string) abort
   return tr(a:string, "\r\n", '  ')
 endfunction
 
+function s:execute(command)
+  execute a:command
+endfunction
+
 ""
 " @function pinnacle#capturel_line
 "
@@ -170,9 +174,13 @@ endfunction
 " embedded newlines.
 "
 function! pinnacle#capture_line(command) abort
-  redir => l:capture
-  execute a:command
-  redir END
+  if exists('*execute')
+    let l:capture=execute(a:command)
+  else
+    redir => l:capture
+    silent call s:execute(a:command)
+    redir END
+  endif
 
   return pinnacle#sub_newlines(l:capture)
 endfunction