Skip to content

E315: ml_get: Invalid lnum: 10 when resizing a (quickfix) window from a filetype autocommand, when splitkeep=screen #11292

@mgedmin

Description

@mgedmin

Steps to reproduce

  1. :set splitkeep=screen
  2. Set up an autocommand like au FileType qf exe "resize" line('$')
  3. Use vim-fugitive's :Ggrep to search for something
  4. Open the quickfix window with :cw
  5. Use :Ggrep again

At this point I get a

E315: ml_get: Invalid lnum: 1

for some line number that corresponds to the previously active quickfix item.

Expected behaviour

New grep results replace old ones, quickfix is resized

Version of Vim

9.0.662

Environment

OS: Ubuntu 22.04 LTS
Terminal: gnome-terminal
TERM: xterm-256color
shell: bash

Logs and stack traces

Error detected while processing function fugitive#GrepCommand[1]..fugitive#Command[77]..function fugitive#GrepCommand[1]..fugitive#Command[7
0]..<SNR>215_GrepSubcommand[52]..<SNR>215_QuickfixCreate[2]..<SNR>215_QuickfixSet[2]..FileType Autocommands for "*"..function <SNR>30_LoadFT
Plugin[18]..script /home/mg/.vim/ftplugin/qf.vim:
line   31:
E315: ml_get: Invalid lnum: 4

Line 31 of https://github.com/mgedmin/dotvim/blob/master/ftplugin/qf.vim#L31 is

exe "resize" line('$')

vim-fugitive's s:QuickfixSet is doing a
call('setqflist', [], ' ', {'title': ':Ggrep ...'})

I was so far unable to reproduce the issue with vim --clean after setting up autocommands and invoking call setqflist().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions