I am having an issue trying to open quickfix list with vim.cmd(copen) and after that prompting for input. The use case is for example to show the list and prompt the user to enter a replacement pattern to replace a previously entered search term which populated the list with vimgrep. The issue i encounter is that nvim is first prompting me with the input and after i insert and confirm with enter, just then the list is opened. This is happening even though the vim.cmd(copen) is called well before the vim.fn.input call. I am probably missing something
vim.cmd('copen') -- i expect to see the list before the echo area is prompting me for input.
local replace = vim.fn.input("Replace pattern: ")
if replace == null or replace == '' then return end
vim.cmd('cdo s#' .. pattern .. '#' .. replace .. '#g')