dashboard-nvim icon indicating copy to clipboard operation
dashboard-nvim copied to clipboard

getting an error when opening nvim-tree while using cat or lolcat to display the header

Open ingenarel opened this issue 1 year ago • 6 comments

Describe the bug i'm getting an error when opening nvim-tree to browse my files when i'm using cat or lolcat to display the header.

To Reproduce Steps to reproduce the behavior:

  1. use a config like this that uses cat or lolcat to display the output:
require("dashboard").setup(
    {
        theme = 'hyper',
        config = {
            packages = {enabled=false},
            project = {enable=false},
            mru = {limit=20},
            footer = {
                "",
                "Live",
                "Not for yourself",
                "But for her."
            },
        },
        preview = {
            command = "lolcat",
            file_path = "~/.config/nvim/lua/_plugins_/karambit-lighter.txt",
            file_height = 19,
            file_width = 59,
        }
    }
)
  1. open up nvim tree
  2. See error:
Error detected while processing WinResized Autocommands for "*":
Error executing lua callback: ...re/nvim/plugged/dashboard-nvim/lua/dashboard/preview.lua:71: attempt to index field 'col' (a number value)                                                                                                    
stack traceback:                                                                                                                                                                                                                               
        ...re/nvim/plugged/dashboard-nvim/lua/dashboard/preview.lua:71: in function 'refresh_preview_wincol'                                                                                                                                   
        ...re/nvim/plugged/dashboard-nvim/lua/dashboard/preview.lua:82: in function <...re/nvim/plugged/dashboard-nvim/lua/dashboard/preview.lua:81>                                                                                           
Press ENTER or type command to continue                                                                                                                                           

image

and if i press esc and try to use it, the header gets messes up. ik the header is another buffer because i can go to the header and open up another file like this: image but it doesn't change the position properly as you can see: image

ingenarel avatar Jul 09 '24 20:07 ingenarel

what terminal is that ? it has to do with not being able to count the columns i cant really get around this because im using neovide

allisonmeow avatar Jul 18 '24 18:07 allisonmeow

what terminal is that ? it has to do with not being able to count the columns i cant really get around this because im using neovide

it's kitty. btw sorry for the late reply.

ingenarel avatar Jul 24 '24 20:07 ingenarel

i cant reproduce this in my default kitty so my guess is it's something to do with your terminfo or youre missing ncurses so it cant call tput cols maybe (total shot in the dark)

allisonmeow avatar Jul 25 '24 05:07 allisonmeow

i checked and i do have ncurses installed. i'm using hyprland on arch. maybe it has something to do with how wayland works or something?

ingenarel avatar Jul 25 '24 07:07 ingenarel

i checked and i do have ncurses installed. i'm using hyprland on arch. maybe it has something to do with how wayland works or something?

I'm not sure this is a Wayland thing, I'm getting the exact same problem in Bash on WSL and ZSH on MacOS.

TheRealGLH avatar Jul 28 '24 20:07 TheRealGLH

I had the same problem (also using Kitty, but I don't believe this has anything to do with the terminal). The issue looks to be spelled out in the traceback @ingenarel posted in the issue. I patched 3 places in preview.lua of my local version of the plugin and it resolved the issue for me. (My issue was triggered when I opened a side panel, Neo-tree, while dashboard was open.)

I don't understand the logic behind col[false]. It seems col will be always be a number or nil. Maybe this is a typo? At any rate, removing the indexing [false] from lines 61 and 71 resolved the error for me. Although, the header (produced by the lolcat output) remains centered in the resized dashboard window, and bleeds into the sidebar window--but I can live with this.

NarvinSingh avatar Sep 02 '24 02:09 NarvinSingh