Skip to content

Conversation

@qstrahl
Copy link
Contributor

@qstrahl qstrahl commented Aug 19, 2019

It always bothered me that the default vim behaviour was to use whatever unrelated window lay at the bottom of the screen to make quickfix jumps. This small patch changes that behaviour so that your first jump after running a quickfix command leaves you in the same window, and furthermore, if you do something like copen to navigate the quickfix window, pressing <Return> will jump you back in the previous window.

Some plugins - for example, tpope's fugitive - trigger custom
QuickFixCmdPost events using :doautocmd. This causes some commands - for
example, :Glgrep - to trigger inappropriate calls to qf#OpenQuickfix
when they should be triggering qf#OpenLoclist, due to the way qf.vim
determines which list to open (by command name).

To solve this, we can cache the value of getqflist() on QuickFixCmdPre,
and check it again on QuickFixCmdPost. If the value has changed, we know
to call qf#OpenQuickfix. Otherwise, we call qf#OpenLoclist. This should
allow for seamless integration with these sorts of plugin commands,
without having to know or care about their names.
@qstrahl
Copy link
Contributor Author

qstrahl commented Sep 10, 2019

@romainl I've gone ahead and found a different, cleaner approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant