Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E36 from quickfix list (smaller than 3 lines) with noequalalways and buftype=nofile #908

Closed
blueyed opened this issue Jul 6, 2016 · 8 comments

Comments

@blueyed
Copy link

blueyed commented Jul 6, 2016

set buftype=nofile
set noequalalways
call setqflist([{'lnum': 1, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': 0, 'type': 'E', 'pattern': '', 'text': 'msg'}])
copen
resize 1

% vim -u minimal.vim

Now going to the quickfix list (C-w j) and pressing Enter will result in "E36: Not enough room".
This happens because the "nofile" buffer will not be re-used to display the error, and when creating a new split apparently :1sp (or even :0sp?!) will be used.

I see the following issues here:

  1. the "nofile" buffer's window could be used directly
  2. in case a new split is needed, the height should not be based on the quickfix/location list, since that is typically small
@blueyed
Copy link
Author

blueyed commented Jul 6, 2016

A similar issue: calling :help from a (quickfix) window with less than 3 lines will also result in E36.
However, when the quickfix window is big enough, the help window is opened, and will have more than just half of the lines from the small (quickfix) window.

@blueyed
Copy link
Author

blueyed commented Jul 6, 2016

I think opening a new window from the quickfix/location list window should result in the same behavior regarding the height as with :help, and both should not trigger the E36 error.

@blueyed
Copy link
Author

blueyed commented Jul 6, 2016

Some dirty workaround:

function! MyQuickfixCR()
  try
    call feedkeys("\<CR>", 'nx')
  catch /:E36:/
    set equalalways
    call feedkeys("\<CR>", 'nx')
    set noequalalways
  endtry
endfunction
autocmd Filetype qf map <buffer> <cr> :call MyQuickfixCR()<cr>

But given how often plugins map <cr> already in quickfix windows, this would need to be enhanced to chain/call any already existing mappings (difficult when looking at what Supertab does in this regard).
And of course setting equalalways (and the new window) will trigger resizing of all (normal) windows..

@vim-ml
Copy link

vim-ml commented Jul 7, 2016

Hi,

On Wed, Jul 6, 2016 at 2:18 PM, Daniel Hahler vim-dev-github@256bit.org
wrote:

set buftype=nofile
set noequalalways
call setqflist([{'lnum': 1, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0,
'nr': 0, 'type': 'E', 'pattern': '', 'text': 'msg'}])
copen
resize 1
% vim -u minimal.vim

Now going to the quickfix list (C-w j) and pressing Enter will result in
"E36: Not enough room". This happens because the "nofile" buffer will
not be re-used to display the error,

Yes. This is by design. When opening a file from the quickfix window,
windows/buffers with 'buftype' set to "nofile" will be skipped. Many plugins
set the 'buftype' to 'nofile' and use the buffer to display some content.
Reusing that window for showing a selected file will impact the plugin.

and when creating a new split apparently :1sp (or even :0sp?!) will
be used.

This is the expected behavior of the 'noequalalways' option.

  • Yegappan

I see the following issues here:

  1. the "nofile" buffer's window could be used directly
  2. in case a new split is needed, the height should not be based on the
    quickfix/location list, since that is typically small

@chrisbra chrisbra closed this as completed Jul 7, 2016
@blueyed
Copy link
Author

blueyed commented Jul 7, 2016

What about making the opening from a qf/loclist window as smart as with :help?

And why should :help fail when opened from a window with less than 3 lines?
And if you would argue that this is the expected behavior with noequalalways, then it would be a bug that :help uses more space than a :sp does, no?

So please consider re-opening it.

@blueyed
Copy link
Author

blueyed commented Jul 14, 2016

@chrisbra
Please consider re-opening the issue with regard to my comment above.

@chrisbra
Copy link
Member

I don't quite understand. There have been too many problems mentioned here. What exactly is your problem?

@blueyed
Copy link
Author

blueyed commented Sep 26, 2016

@chrisbra
Basically the question above:
If you use noequalalways you cannot open entries from a quickfix list when it is smaller than 3 lines, and even it is 3 lines or more, it will only use 1 for the height of the new window then.

set buftype=nofile
set noequalalways
call setqflist([{'lnum': 1, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': 0, 'type': 'E', 'pattern': '', 'text': 'msg'}])
copen
resize 1

Run it with vim -Nu vimrc-e36.vim -c '2wincmd w' and press Enter: E36: Not enough room.
Then do a :3wincmd _ and press Enter again: you get a window but with the height of only 1 line.

I like to use noequalalways, because I do not like the automatic resizing.

While :help also fails from the quickfix window of height 1, it behaves sane when the qf height is 3.

So you are right: there are several issues, but it boils down to:

  1. :help should work from a (qf) window with less than 3 lines
  2. the quickfix opening should be as sensible as :help is (with 1. being fixed of course).

I think those issues are really related.
Should I separate them?

Besides preferring noequalalways, I also have autocommands that resize the location/quickfix lists to only display as many lines as possible, and that's why I often run into this issue - but in general only if the existing window (besides the qf list is of buftype=nofile, of course).

FWIW here is my current workaround:

function! MyQuickfixCR()
  let prev_map = "\<Plug>MyQuickfixCRPre"
  exe 'nunmap <buffer> <cr>'
  try
    call feedkeys(prev_map, 'x')
  catch /:E36:/
    set equalalways
    try
      call feedkeys(prev_map, 'x')
    finally
      set noequalalways
    endtry
  finally
    exe 'map <buffer> <cr> :call MyQuickfixCR()<cr>'
  endtry
endfunction
function! SetupMyQuickfixCR()
  let cr_map = ':call MyQuickfixCR()<cr>'
  if maparg('<cr>', 'n') == cr_map
    " Already setup, don't do it twice.
    return
  endif
  let prev_map = maparg('<cr>', 'n')
  if !len(prev_map)
    let prev_map = "\<CR>"
  endif
  exe 'nmap <buffer> <Plug>MyQuickfixCRPre '.prev_map
  exe 'nmap <buffer> <cr> '.cr_map
endfunction
call SetupMyQuickfixCR()

This handles existing mappings from e.g. Vader, and chains/wraps them.

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

No branches or pull requests

3 participants