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

Quickfix lists with many entries can mess up window arrangements #4129

Open
11 of 12 tasks
Aster89 opened this issue Feb 14, 2023 · 6 comments
Open
11 of 12 tasks

Quickfix lists with many entries can mess up window arrangements #4129

Aster89 opened this issue Feb 14, 2023 · 6 comments

Comments

@Aster89
Copy link
Contributor

Aster89 commented Feb 14, 2023

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) before filing your issue:

  • I have read and understood YCM's CONTRIBUTING document.
  • I have read and understood YCM's CODE_OF_CONDUCT document.
  • I have read and understood YCM's README, especially the
    Frequently Asked Questions section.
  • I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. (Example Google
    search.
    )
  • If filing a bug report, I have included the output of vim --version.
  • If filing a bug report, I have included the output of :YcmDebugInfo.
  • If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • If filing a bug report, I have included a minimal test case that reproduces
    my issue, using vim -Nu /path/to/YCM/vimrc_ycm_minimal, including what I
    expected to happen and what actually happened.
  • If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt gift of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

Provide a clear description of the problem, including the following key
questions:

  • What did you do?

Include steps to reproduce here.

  1. vim -Nu /path/to/YCM/ycm_vimrc_minimal someNewFile.cpp where the content of the file is below (yeah, the file is not new, ahah)
  2. :tabe minimalVimrc.vim, where the content of this file is below
  3. :so %
  4. gt (go to tab with c++ file)
  5. spaceds3EnterEnter (start debugger)
  6. Ctrl+Wk (move to source code)
  7. :YcmCompleter GoToSymbol find
  8. observe
  9. Ctrl+Wp (go back to previous win, thus closing the quickfix window too)
  10. :set noequalalways
  11. repeat step 7-9
  12. observe

Include description of a minimal test case, including any actual code required
to reproduce the issue.

#include <any>
#include <array>
#include <deque>
#include <functional>
#include <memory>
#include <unordered_map>
#include <vector>

using namespace std;

int main () {}

If you made changes to vimrc_ycm_minimal, pase them here:

" I source this after opening Vim with your minimal vimrc
let mapleader = "\<Space>"

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  au VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')

Plug 'junegunn/vim-plug'
Plug 'Valloric/YouCompleteMe'
Plug 'puremourning/vimspector'
call plug#end()

syntax enable " move this somewhere more appropriate

nnoremap          <leader>ygs :YcmCompleter GoToSymbol<Space>
function! s:CustomizeYcmLocationWindow()
  "wincmd K
  5wincmd _
  wincmd p
endfunction
autocmd User YcmLocationOpened call s:CustomizeYcmLocationWindow()
function! s:CustomizeYcmQuickFixWindow()
  5wincmd _
endfunction
autocmd User YcmQuickFixOpened call s:CustomizeYcmQuickFixWindow()

let g:vimspector_toggle_disables_breakpoint = 1
let g:vimspector_base_dir = environ().HOME .. '/.vim/plugged/vimspector'
let g:vimspector_sign_priority = {
    \    'vimspectorBP':         11,
    \    'vimspectorBPCond':     11,
    \    'vimspectorBPLog':      11,
    \    'vimspectorBPDisabled': 11,
    \    'vimspectorPC':         11,
    \ }
nnoremap <leader>ds :call vimspector#Launch()<CR>
nnoremap <leader>dq :VimspectorReset<CR>
nnoremap <leader>ygs :YcmCompleter GoToSymbol<Space>
nmap <leader>db <Plug>VimspectorToggleBreakpoint
nmap <leader>dB <Plug>VimspectorBreakpoints
nmap <leader>dr <Plug>VimspectorRestart
  • What did you expect to happen?

Resizing more friendly towards existing windows layout

  • What actually happened?

Windows are messed up.

See screencast:

asciicast

Diagnostic data

Output of vim --version

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Feb 11 2023 18:31:20)
Included patches: 1-1302
Compiled by Arch Linux
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +cindent           +cursorshape       +file_in_path      +job               +menu              +mouse_urxvt       +popupwin          +signs             -tag_any_white     +user_commands     +windows
+arabic            +clientserver      +dialog_con_gui    +find_in_path      +jumplist          +mksession         +mouse_xterm       +postscript        +smartindent       +tcl/dyn           +vartabs           +writebackup
+autocmd           +clipboard         +diff              +float             +keymap            +modify_fname      +multi_byte        +printer           -sodium            +termguicolors     +vertsplit         +X11
+autochdir         +cmdline_compl     +digraphs          +folding           +lambda            +mouse             +multi_lang        +profile           +sound             +terminal          +vim9script        -xfontset
-autoservername    +cmdline_hist      +dnd               -footer            +langmap           +mouseshape        -mzscheme          -python            +spell             +terminfo          +viminfo           +xim
+balloon_eval      +cmdline_info      -ebcdic            +fork()            +libcall           +mouse_dec         +netbeans_intg     +python3/dyn       +startuptime       +termresponse      +virtualedit       -xpm
+balloon_eval_term +comments          +emacs_tags        +gettext           +linebreak         +mouse_gpm         +num64             +quickfix          +statusline        +textobjects       +visual            +xsmp_interact
+browse            +conceal           +eval              -hangul_input      +lispindent        -mouse_jsbterm     +packages          +reltime           -sun_workshop      +textprop          +visualextra       +xterm_clipboard
++builtin_terms    +cryptv            +ex_extra          +iconv             +listcmds          +mouse_netterm     +path_extra        +rightleft         +syntax            +timers            +vreplace          -xterm_save
+byte_offset       +cscope            +extra_search      +insert_expand     +localmap          +mouse_sgr         +perl/dyn          +ruby/dyn          +tag_binary        +title             +wildignore
+channel           +cursorbind        -farsi             +ipv6              +lua/dyn           -mouse_sysmouse    +persistent_undo   +scrollbind        -tag_old_static    +toolbar           +wildmenu
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freet
ype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cloudproviders -I
/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -pthread -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/vim/src=/usr/src/debug/vim -flto=auto -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.36/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto -L/usr/local/lib -o vim -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gob
ject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lcanberra -lacl -lattr -lgpm -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.36/core_perl/CORE -Wl,-O1,--sort-common,--a
s-needed,-z,relro,-z,now -flto=auto -fstack-protector-strong -L/usr/local/lib -L/usr/lib/perl5/5.36/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Resolve completions: Up front
-- Client logfile: /tmp/ycm_di1z9444.log
-- Server Python interpreter: /usr/bin/python3
-- Server Python version: 3.10.9
-- Server has Clang support compiled in: True
-- Clang version: clang version 15.0.1 (https://github.com/ycm-core/llvm 708056a3d8259ce1d9fc0f15676d13b53cc23835)
-- Extra configuration file found and loaded
-- Extra configuration path: /home/enrico/.ycm_extra_conf.py
-- C-family completer debug information:
--   Clangd running
--   Clangd process ID: 1575854
--   Clangd executable: ['/home/enrico/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/clangd/output/bin/clangd', '-header-insertion-decorators=0', '-resource-dir=/home/enrico/.vim/plugged/YouCompleteMe/third_party/ycmd/thir
d_party/clang/lib/clang/15.0.1', '-limit-results=500', '-log=verbose']
--   Clangd logfiles:
--     /tmp/clangd_stderrsbad7lks.log
--   Clangd Server State: Initialized
--   Clangd Project Directory: /home/enrico
--   Clangd Settings: {}
--   Clangd Compilation Command: ['clang-tool', '-x', 'c++', '-std=c++20', '-Wall', '-Wextra', '-Wattributes', '/home/enrico/someNewFile.cpp']
-- Server running at: http://127.0.0.1:50905
-- Server process ID: 1575780
-- Server logfiles:
--   /tmp/ycmd_50905_stdout_ayn0nm8a.log
--   /tmp/ycmd_50905_stderr_y3xchte3.log
-- Semantic highlighting supported: True
-- Virtual text supported: True
-- Popup windows supported: True

Output of YcmDiags

No warnings or errors detected.

Output of git rev-parse HEAD in YouCompleteMe installation directory

9a5eb4443e8a990698daa99da512d0fd7aed0f32

Contents of YCM, ycmd and completion engine logfiles

Reproduce the issue with vim -Nu /path/to/YCM/vimrc_ycm_minimal, which
enabled debug logging and other useful diagnostics. Include a link to a
gist containing all of the log files listed by :YcmToggleLogs.

OS version, distribution, etc.

Up-to-date ArchLinux

Output of build/install commands

Include link to a gist containing the invocation and entire output of
install.py if reporting an installation issue.

@puremourning
Copy link
Member

The reason for this is fairly obvious, if you remove most of your customisations and make it actually minimal.

When you do "YcmCompleter GoToSymbol find", YCM opens the quick fix window to fill the screen:

Screenshot 2023-02-15 at 08 41 03

Your auto command, invoked after the quick fix window is opened, then shrinks it.

One solution is to to set b:ycm_no_resize to 1 in the quick fix buffer using an autocmd, which prevents the initial auto-sizing of the quickfix/location list window. Its purpose is to do exactly what you want, which is allow your autocommand/quickfixheight settings to specify the quick fix height. I added this for my VerticalQuickFix plugin

So this will work for you:

    augroup DisableYcmResizeInQuickFix
        au!
        autocmd FileType qf let b:ycm_no_resize=1
    augroup END

Admittedly, that's a) undocumented and b) super fiddly, but hopefully it's enough for now.

@puremourning puremourning changed the title Weird window resizing when quickfix opens with many rows Quickfix lists with many entries can mess up window arrangements Feb 15, 2023
@puremourning
Copy link
Member

We may be able to do something clever with winsaveview() and winrestview() but that will require some careful testing and investigation.

@Aster89
Copy link
Contributor Author

Aster89 commented Feb 16, 2023

I don't see b:ycm_no_resize in the YCM doc. Is that the thing you say is undocumented?

@puremourning
Copy link
Member

I don't see b:ycm_no_resize in the YCM doc. Is that the thing you say is undocumented?

Yes

@Aster89
Copy link
Contributor Author

Aster89 commented May 28, 2023

Sorry to come back to this, but I think the main problem is that I have set noequalalways in my vimrc. I like to have it, but I see that it affects what happens when the quickfix in question is closed. Do you have any suggestions?

@Aster89
Copy link
Contributor Author

Aster89 commented May 28, 2023

In any case, even with the following vimrc, after closing GoToSymbol's quickfix window, the original layout is not recovered, as the console which occupied only a few lines now occupies half of the space.

let maplocalleader = "\<Backspace>"
let mapleader = "\<Space>"

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  au VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')

Plug 'Valloric/YouCompleteMe'
Plug 'puremourning/vimspector'
call plug#end()

syntax enable " move this somewhere more appropriate

nnoremap          <leader>ygs :YcmCompleter GoToSymbol<Space>

let g:vimspector_toggle_disables_breakpoint = 1
let g:vimspector_base_dir = environ().HOME .. '/.vim/plugged/vimspector'
nnoremap <leader>ds :call vimspector#Launch()<CR>
nnoremap <leader>dq :VimspectorReset<CR>
nmap <leader>dS <Plug>VimspectorStop
nmap <leader>dr <Plug>VimspectorRestart
nmap <leader>db <Plug>VimspectorToggleBreakpoint

augroup DisableYcmResizeInQuickFix
    au!
    autocmd FileType qf let b:ycm_no_resize=1
augroup END

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

2 participants