Skip to content

WinLeave error when opening Go tests in new tab  #108

@kossmar

Description

@kossmar

Neovim version (nvim -v | head -n1)

NVIM v0.7.2

Operating system/version

macOS 10.15.7

How to reproduce the issue

  1. Install plugins:
  1. Install golang

  2. Add this function to init.vim

command Test call <SID>maketest()
function! s:maketest()
    if TabooTabName(tabpagenr()) == "maketest"
        AsyncRun -raw make test
        set filetype=text
    else
        AsyncRun -raw make test
        copen

        " move the error window to a new tab (see :help window-moving)
        exe "normal \<c-w>T" 
        TabooRename maketest
        set filetype=text
    endif
endfunction
  1. call :Test in nvim

Expected behavior

Should open the tests in a new tab. And it does but I have to click through an error as specified below.

Actual behavior

Same as the expected behaviour but I have to click through this error.

Error detected while processing WinLeave Autocommands for "<buffer=3>":                                                                       
E5108: Error executing lua .../.config/nvim/plugged/nvim-bqf/lua/bqf/qfwin/session.lua:96: attempt to index local 'obj' (a nil value)         
stack traceback:                                                                                                                              
        .../.config/nvim/plugged/nvim-bqf/lua/bqf/qfwin/session.lua:96: in function 'saveWinView'                                             
        ...s/markoss/.config/nvim/plugged/nvim-bqf/lua/bqf/main.lua:103: in function 'saveWinView'  

Screen Shot 2023-03-13 at 4 16 59 PM

I fixed it by adding a nil check to lua/bqf/qfwin/session.lua and this stopped the errors but I don't know if it might break something else...?

function QfSession:saveWinView(winid)
    if winid then
        local obj = self.pool[winid]
        local wv = utils.winCall(winid, fn.winsaveview)
        if obj ~= nil then
            obj:list():setWinView(wv)
        end
    end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions