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

Random error messages when quickly moving tabs #590

Open
nonetrix opened this issue Jun 22, 2024 · 6 comments
Open

Random error messages when quickly moving tabs #590

nonetrix opened this issue Jun 22, 2024 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@nonetrix
Copy link

Description

When quickly moving tabs you will get a lot of errors randomly, I assume I could just turn these off and ignore them automatically somehow. However, this seems like plugin itself has a bug that causes this in the first place and it should be fixed at the root. Here is a example of one I got quickly dragging tabs with mouse on Kitty

Error executing vim.schedule lua callback: ...yNeovimPackages/start/barbar.nvim/lua/barbar/animate.lua:43: attempt to perform arithmetic on local 'final' (a nil value)                                           
stack traceback:                                                                                                                                                                                                  
        ...yNeovimPackages/start/barbar.nvim/lua/barbar/animate.lua:43: in function 'lerp'                                                                                                                        
        ...ck/myNeovimPackages/start/barbar.nvim/lua/barbar/api.lua:232: in function 'move_buffer_animated_tick'                                                                                                  
        ...ck/myNeovimPackages/start/barbar.nvim/lua/barbar/api.lua:308: in function 'fn'                                                                                                                         
        ...yNeovimPackages/start/barbar.nvim/lua/barbar/animate.lua:59: in function 'animate_tick'                                                                                                                
        ...yNeovimPackages/start/barbar.nvim/lua/barbar/animate.lua:88: in function ''                                                                                                                            
        vim/_editor.lua: in function <vim/_editor.lua:0>

To Reproduce

  1. Quickly drag tabs back and forth quickly for a bit
  2. Observe

init.vim:

It's in Nix sorry :(

{...}: let
  global = import ../global-var.nix;
in {
  home-manager.users.${global.username} = {pkgs, ...}: {
    programs.neovim = {
      enable = true;
      defaultEditor = true;
      extraConfig = ''
        syntax on
        set number relativenumber
        set autoindent
        set tabstop=4
        set ignorecase
        set ttyfast
        set termguicolors
        set expandtab
        set cmdheight=0
      '';

      extraLuaConfig = ''
        vim.cmd.colorscheme "catppuccin"

        require('nvim-tree').setup {
          tab = { sync = { open = true, close = true, ignore = {} } },
        }

        require('lualine').setup {
          options = {
            theme = "catppuccin",
            disabled_filetypes = {
              statusline = {"NvimTree"},
            },
          },
        }

        require'colorizer'.setup {
          filetypes = {
            '*',
          },
        }

        vim.api.nvim_create_autocmd("FileType", {
          pattern = "nix",
          callback = function()
          vim.bo.expandtab = true
          vim.bo.shiftwidth = 2
          vim.bo.tabstop = 2
          vim.bo.softtabstop = 2
        end,
      })

      vim.api.nvim_create_autocmd('TextYankPost', {
        desc = 'Highlight when yanking (copying) text',
        group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
        callback = function()
          vim.highlight.on_yank()
        end,
      })

        require("nvim-autopairs").setup {}
        require("ibl").setup {}

        local function open_nvim_tree()
          -- open the tree
          require("nvim-tree.api").tree.open()
        end

        -- vim.api.nvim_create_autocmd("VimEnter", { callback = open_nvim_tree })
        -- vim.api.nvim_create_autocmd("TabEnter", { callback = open_nvim_tree })

        vim.api.nvim_set_keymap('n', '<F2>', ':NvimTreeToggle<CR>', { noremap = true, silent = true })

        if vim.g.neovide then
          vim.o.guifont = "iosevka Nerd Font:h12"
          vim.g.neovide_transparency = 0.9
        end
      '';

      plugins = with pkgs.vimPlugins; [
        catppuccin-nvim
        nvim-tree-lua
        nvim-web-devicons
        barbar-nvim
        lualine-nvim
        nvim-colorizer-lua
        nvim-autopairs
        indent-blankline-nvim
        nvim-treesitter.withAllGrammars
      ];
    };
  };
}

Steps to reproduce the behavior:

  1. Why are you asking me twice?

Screenshots
image

Informations (note information is misspelled here in the template, small mistake but I noticed. Best of luck no harm meant:-) )
Neovim version: v0.10.0

@nonetrix
Copy link
Author

Note: I am on 165Hz monitor, perhaps it sends mouse events quicker or something? Just a guess

@Iron-E Iron-E added the bug Something isn't working label Jun 25, 2024
@Iron-E
Copy link
Collaborator

Iron-E commented Jun 25, 2024

Potentially related: #550

@nonetrix
Copy link
Author

Luckily doesn't seem to cause many issues, is there way to suppress these errors until a fix?

@Iron-E
Copy link
Collaborator

Iron-E commented Jun 26, 2024

Not a clean one 😅

I'll try to take a look at this soon.

@Iron-E
Copy link
Collaborator

Iron-E commented Jun 28, 2024

Took a quick look at this, just reporting my findings so far (side note: I actually use nix myself, so I was able to drop your config right into mine without hassle!)

I was able to reproduce the issue right away with the config

Edit: I created a minimal repro that works with my config too

--[[ minimal.lua ]]
local lazy = vim.fn.stdpath('data') .. '/lazy/'
vim.opt.rtp:prepend {
  lazy .. 'barbar.nvim',
  lazy .. 'nvim-web-devicons',
}

vim.g.barbar_auto_setup = false
require('barbar').setup {
  -- additional options
}

-- additional code

vim.api.nvim_create_autocmd('VimEnter', {
  callback = vim.schedule_wrap(function()
    -- additional post-startup code
    vim.cmd [[
      for file in ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "x", "y", "z"]
        execute "edit " .. file
      endfor
    ]]
  end),
})

@nonetrix for now setting animate = false in your barbar config should fix it. I'll let you know when we have a real fix

@Iron-E
Copy link
Collaborator

Iron-E commented Jun 28, 2024

I set up some debug logging to inspect this further, and captured the following state here:

{
  current_animation = {
    current = 0,
    duration = 150,
    final = 1,
    fn = <function 1>,
    initial = 0,
    running = true,
    start = 6703368.801163,
    timer = <userdata 1>,
    type = 5
  },
  current_data = {
    closing = false,
    computed_position = 0,
    computed_width = 12,
    diagnostics = { 0, 0, 0, 0 },
    gitsigns = {
      added = 0,
      changed = 0,
      deleted = 0
    },
    moving = false,
    name = "a",
    pinned = false,
    will_close = false
  },
  current_number = 1,
  move_animation_data = {},
  ratio = 0.93393590000148
}

This leads me to believe that the problem is manifesting here, as the move_animation_data is empty (which causes the arithmetic error we see in lerp).

It seems move_animation_data is set just before move_buffer_animated_tick is called right here, which means previous_positions and next_positions must also be nil by this point

@Iron-E Iron-E added this to the backlog milestone Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants