Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ToggleTermSetName does not work with count #496

Closed
1 task done
abhinavnatarajan opened this issue Sep 27, 2023 · 1 comment · Fixed by #497 or #498
Closed
1 task done

[BUG] ToggleTermSetName does not work with count #496

abhinavnatarajan opened this issue Sep 27, 2023 · 1 comment · Fixed by #497 or #498

Comments

@abhinavnatarajan
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Calling ToggleTermSetName with a count opens the dialogue to enter a new name, and typing a name and hitting <CR> results in the error "attempt to index local 'term' (a nil value)".

Expected Behavior

The specified terminal should be renamed without error.

Steps To Reproduce

  1. Minimal init.lua to reproduce the above behaviour:
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable', -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

-- Lazy load plugins
require("lazy").setup {
  {
    'akinsho/toggleterm.nvim',
    version = "*",
    lazy = true,
    cmd = {
      'ToggleTerm',
      'TermSelect',
      "ToggleTermSendCurrentLine",
      "ToggleTermSendVisualLines",
      "ToggleTermSendVisualSelection",
      "ToggleTermSetName",
    },
    keys = { [[<C-`>]] },
    config = function ()
      require("toggleterm").setup {
        open_mapping = [[<C-`>]],
        insert_mappings = true, -- whether or not the open mapping applies in insert mode
        terminal_mappings = true, -- whether or not the open mapping applies in the opened terminals
        close_on_exit = true, -- close the terminal window when the process exits
        -- Change the default shell. Can be a string or a function returning a string
        shell = vim.o.shell,
        auto_scroll = true, -- automatically scroll to the bottom on terminal output
        -- This field is only relevant if direction is set to 'float'
      }
	  vim.keymap.set('n', '<A-r>', '<CMD>ToggleTermSetName<CR>', {noremap = true})
    end
  }
}
  1. Run:
    a. Create two terminals with <C-`><Esc>2<C-`><Esc>.
    c. Type 2<A-r>.

Environment

- OS: Ubuntu 22.04.2 LTS running as a WSL2 distro in Windows 11
- neovim version: 0.9.2
- Shell: bash
- Terminal: wezterm

Anything else?

Thanks for your work on this plugin, I rely on it quite extensively!

@abhinavnatarajan
Copy link
Contributor Author

Added PR #497 to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant