FTerm.nvim icon indicating copy to clipboard operation
FTerm.nvim copied to clipboard

Error executing lua: ...site/pack/packer/start/FTerm.nvim/lua/FTerm/terminal.lua:109: Window was closed immediately

Open nyngwang opened this issue 3 years ago • 5 comments

How to Reproduce:

  1. Install plugin called fzf-lua
  2. Open any one of its floating windows, e.g. FzfLua buffers
  3. Execute cmd :lua require("FTerm").toggle()

Friendly linked to the error line: https://github.com/numToStr/FTerm.nvim/blob/eabb65f23ba48ec9e8abb9a2514f99b77b3bc6f2/lua/FTerm/terminal.lua#L109

nyngwang avatar Jan 17 '22 06:01 nyngwang

For anyone who is reading try this modified keymap:

vim.keymap.set({'n', 't'}, '<M-Tab>', function ()
  if (vim.api.nvim_win_get_config(0).relative ~= '') then
    vim.api.nvim_input('<ESC>')
  end
  require('FTerm').toggle()
end, NOREF_NOERR_TRUNC)

the little non-harmful drawback is that you will need to press the keymap twice to close the existing floating window and open the terminal.

nyngwang avatar Jan 17 '22 07:01 nyngwang

I hope this can be taken into consideration. So users won't have to solve it themselves painly.

nyngwang avatar Jan 17 '22 07:01 nyngwang

I'll investigate what is causing this.

numToStr avatar Jan 17 '22 09:01 numToStr

I'll investigate what is causing this.

@numToStr Thanks :)

For anyone who is reading try this modified keymap:

vim.keymap.set({'n', 't'}, '<M-Tab>', function ()
  if (vim.api.nvim_win_get_config(0).relative ~= '') then
    vim.api.nvim_input('<ESC>')
  end
  require('FTerm').toggle()
end, NOREF_NOERR_TRUNC)

And I just found a much simpler solution hours ago. But this one doesn't facilitate the newest syntax. It still need to use <cmd>..., which is what I don't like:

vim.keymap.set({'n', 't'}, '<M-Tab>', "<cmd>silent! lua require('FTerm').toggle()<CR>", { nowait=true, noremap=true, silent=true })

nyngwang avatar Jan 17 '22 18:01 nyngwang

Friendly linked to the error line:

https://github.com/numToStr/FTerm.nvim/blob/eabb65f23ba48ec9e8abb9a2514f99b77b3bc6f2/lua/FTerm/terminal.lua#L109

I am running into the same issue with Telescope.

marcoSven avatar Oct 18 '23 12:10 marcoSven