GithubHelp home page GithubHelp logo

Comments (33)

ZyX-I avatar ZyX-I commented on September 23, 2024 8

@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.

from ack.vim.

Kagami avatar Kagami commented on September 23, 2024 6

On my system (Linux, zsh) simple setting set shellpipe=> in .vimrc solved the problem.

from ack.vim.

jonathankau avatar jonathankau commented on September 23, 2024 3

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! 😄

from ack.vim.

skamsie avatar skamsie commented on September 23, 2024 2

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?

from ack.vim.

mcadam avatar mcadam commented on September 23, 2024 1

@skamsie Just added that set shellpipe=> to my .vimrc and fixed it in the meantime.

from ack.vim.

osaris avatar osaris commented on September 23, 2024

Same here (on debian lenny) but no problem with MVim.

from ack.vim.

chriskempson avatar chriskempson commented on September 23, 2024

Happens to me also when running in a terminal. My entire screen flashes the output of Ack then back to Vim again. Rather distracting.

from ack.vim.

owenthereal avatar owenthereal commented on September 23, 2024

Happen to me on terminal vim, is there any fix for this?

from ack.vim.

adamcooper avatar adamcooper commented on September 23, 2024

+1 on this issue too. Only in vim not MacVim.

from ack.vim.

8bitDesigner avatar 8bitDesigner commented on September 23, 2024

Just ran into this too; on iTerm2 with vim 7.3

from ack.vim.

reicheltd avatar reicheltd commented on September 23, 2024

+1 same problem here. Output is something like: [2] + 29217 suspended (tty output)

from ack.vim.

stephenmckinney avatar stephenmckinney commented on September 23, 2024

+1 same here. vim 7.3 in iTerm2.

from ack.vim.

xnzac avatar xnzac commented on September 23, 2024

+1, also on iTerm2 with Vim 7.3.

from ack.vim.

ticviking avatar ticviking commented on September 23, 2024

I'm experiencing the same issue, any idea what is causing that?

from ack.vim.

rogeliog avatar rogeliog commented on September 23, 2024

+1, also on iTerm2 with Vim 7.3.

from ack.vim.

FreekKalter avatar FreekKalter commented on September 23, 2024

+1 Same issue here.
OSX 10.7.5, iTerm2, Vim 7.3

from ack.vim.

mileszs avatar mileszs commented on September 23, 2024

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.

from ack.vim.

rvega avatar rvega commented on September 23, 2024

+1 I'm on Ubuntu 12.04, gnome terminal and vim 7.3

from ack.vim.

rvega avatar rvega commented on September 23, 2024

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: #52

from ack.vim.

ZyX-I avatar ZyX-I commented on September 23, 2024

@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.

from ack.vim.

mileszs avatar mileszs commented on September 23, 2024

We should definitely try to find a cross-platform solution.

from ack.vim.

mileszs avatar mileszs commented on September 23, 2024

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?

from ack.vim.

ZyX-I avatar ZyX-I commented on September 23, 2024

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.

from ack.vim.

tim-vfiles avatar tim-vfiles commented on September 23, 2024

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.

from ack.vim.

solidcell avatar solidcell commented on September 23, 2024

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.

from ack.vim.

solidcell avatar solidcell commented on September 23, 2024

Thanks for the advice @Kagami. However, it didn't work for me (on OSX 10.8.2 using zsh).

from ack.vim.

kassio avatar kassio commented on September 23, 2024

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=

from ack.vim.

lesguillemets avatar lesguillemets commented on September 23, 2024

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.

from ack.vim.

ekouters avatar ekouters commented on September 23, 2024

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!

from ack.vim.

sfahlberg avatar sfahlberg commented on September 23, 2024

@Kagami that worked for me- thanks!

from ack.vim.

mcadam avatar mcadam commented on September 23, 2024

Same issue for me with vim 8 on mac

from ack.vim.

yevhen-m avatar yevhen-m commented on September 23, 2024

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

from ack.vim.

soraliu avatar soraliu commented on September 23, 2024

@jonathankau Thank you! It works.

from ack.vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.