Closed jerodsanto closed 10 years ago
Same here (on debian lenny) but no problem with MVim.
Happens to me also when running in a terminal. My entire screen flashes the output of Ack then back to Vim again. Rather distracting.
Happen to me on terminal vim, is there any fix for this?
+1 on this issue too. Only in vim not MacVim.
Just ran into this too; on iTerm2 with vim 7.3
+1 same problem here. Output is something like: [2] + 29217 suspended (tty output)
+1 same here. vim 7.3 in iTerm2.
+1, also on iTerm2 with Vim 7.3.
I'm experiencing the same issue, any idea what is causing that?
+1, also on iTerm2 with Vim 7.3.
+1 Same issue here. OSX 10.7.5, iTerm2, Vim 7.3
I'm seeing it as well. I will look into it as soon as I can. If someone else has code that fixes it immediately, please note it here.
+1 I'm on Ubuntu 12.04, gnome terminal and vim 7.3
This fixed it for me. Thanks to ZyX in stack overflow: http://stackoverflow.com/questions/13322161/ack-in-terminal-vim-is-flashing-its-output-before-presenting-search-results-ho/13322352#13322352
let grepprg_bak=&grepprg
let grepformat_bak=&grepformat
let shellpipe_bak=&shellpipe
try
let &shellpipe="&>"
let &grepprg=g:ackprg
let &grepformat=g:ackformat
silent execute a:cmd . " " . escape(l:grepargs, '|')
finally
let &shellpipe=shellpipe_bak
let &grepprg=grepprg_bak
let &grepformat=grepformat_bak
endtry
Pull request: https://github.com/mileszs/ack.vim/pull/52
@rvega It is bad idea to unconditionally use this fix: it is non-crossplatform, even on linux it may be wrong depending on value of the &shell
option.
We should definitely try to find a cross-platform solution.
ZyX-I, do you know in what instances specifically this will fail? What is the result of a failure? For instance, will one simply continue seeing the current odd behavior, or does it crash hard?
do you know in what instances specifically this will fail?
With cmd.exe
, tcsh
and dash
definitely. csh
should fail as well, but I have not tested.
What is the result of a failure?
cmd.exe
: unknown command (&
is the same as ;
in bash AFAIK).
dash
: ack is launched in the background and output is not get redirected appearing only in terminal (no support for stdout+stderr redirection with &>
, hence ampersand has its usual meaning: launch in background).
tcsh
: “invalid null command” error, nothing seems to be actually executed (different syntax).
For instance, will one simply continue seeing the current odd behavior, or does it crash hard?
It does not crash. Nor it does work, none of the variants result in target file being written to.
This is a thing that is supposed to be fixed in vimrc, if you are absolutely sure nobody needs viewing command output temporary before ack finishes you should switch to system()
, manual parsing of ack output and setqflist
/setloclist
. Writing to terminal is not a requirement for &shellpipe
(does not do so for cmd.exe
), just somebody thought it would be convenient for long-running commands (I guess). Setting it in the vimrc won’t break anything.
I definitely have no idea how such &shellpipe
overriding works in powershell, fish, ksh, ash, psh (is it useful as default shell in vim at all?) and a number of shells I don’t even know about. And I am absolutely sure if you want to fix this by overriding &shellpipe
then you end up with a big if..elsif..else..endif
block.
On Kubuntu 12.04 I see the flashing regardless of whether I'm using vim in the terminal or start gvim from krunner, and after flashing my top buffer has already been changed to show the top result.
In OSX 10.6 I've been having the same problems. In the terminal it will background vim while running the ack command. In MacVim it will just freeze until I quit (MacVim, not the command). Different terminals and shells make no difference.
On my system (Linux, zsh) simple setting set shellpipe=>
in .vimrc
solved the problem.
Thanks for the advice @Kagami. However, it didn't work for me (on OSX 10.8.2 using zsh).
It's a default behaviour on vim use the same terminal session where vim was open to run system commands, with that when you closes vim the output of ran commands will be on terminal. To change this vim's default behaviour use: set t_ti= t_te=
In that case, does preserving the values &t_ti
and &t_te
just before called, then set t_ti= t_te=
, call ack, and restoring initial values (let &t_ti = saved_value_for_t_ti
) work as a fix?
This just occurred to me and I haven't dig into the possibility, so I'm sorry if I'm just showing stupidity.
This is still an issue for me. @kassio suggests changing vim's default behavior, but this is no option for me. @lesguillemets links to an issue which was solved with a commit that worked for me. Thanks!
@Kagami that worked for me- thanks!
I just installed the plugin and I notice I actually have this problem. Using vim on mac
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 6 2017 06:58:22)
MacOS X (unix) version
Included patches: 1-311
Compiled by Homebrew
Can someone confirm this and maybe reopen the issue?
Same issue for me with vim 8 on mac
@skamsie Just added that set shellpipe=>
to my .vimrc and fixed it in the meantime.
I have this issue as well, output is printed on the screen and distracts a lot. set shellpipe=>
fixes this indeed. Is it the best way to solve this issue?
neovim, osx, iterm
Adding set shellpipe=>
does fix the issue, but it also blocks shell output from other plugins (like fugitive).
I ended up writing a Vimscript function that takes in the search param and makes sure to set/unset shellpipe properly:
function! Search(string)
set shellpipe=>
execute "Ack! \"" . a:string . "\""
set shellpipe=2>&1\|tee
endfunction
nnoremap <C-F> :call Search("")<left><left>
EDIT: Looks like @ZyX-I pointed out a couple issues with my implementation. I'm not very well-versed in Vimscript, so thanks for the help! 😄
@jonathankau This can hardly be considered “properly”. Correct variant is using 1. original &shellpipe
value and not anything hardcoded, 2. finally
and 3. shelleescape()
:
function Search(string) abort
let saved_shellpipe = &shellpipe
let &shellpipe = '>'
try
execute 'Ack!' shellescape(a:string, 1)
finally
let &shellpipe = saved_shellpipe
endtry
endfunction
. Note though that I may be incorrect regarding escaping here though: it is definitely correct variant for ag.vim
, but I am no longer using ack.vim
.
@jonathankau Thank you! It works.
When I run vim from OS X's (10.6.7) Terminal or iTerm apps and use the
Ack
command it works as expected, but upon closing vim all of the search results have been printed in the terminal window.This does not occur when using MacVim even if it is launched via the
mvim
command.