What is the best way to distinguish the current buffer is location list or quickfix list?

前端 未结 4 1900

I have an autocmd, if ft is qf, it is gonna call some functions to modify the quickfix list by get/setqflist()

I know there ar

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-02 05:46

    The only reliable way I've found, is to store the current window number, then issue a :copen command. If the active window number changes, you were in the location list and not the quickfix list. If it doesn't change, you were already in the quickfix list.

    You also want to store the number of open windows, and compare that to the new number of open windows. Then you can close the quickfix window if it wasn't already open.

    Finally you can jump back to the location list (if needed) using the stored window number and wincmd w.

提交回复
热议问题