nvimdev / dashboard-nvim

vim dashboard
MIT License
2.19k stars 177 forks source link

Improper cursor position for multichar unicode #465

Open Owen000 opened 4 days ago

Owen000 commented 4 days ago

Describe the bug I am still experiencing the issue that was solved here: https://github.com/nvimdev/dashboard-nvim/issues/422 multibyte chars move my cursor to the improper positioning.

To Reproduce Steps to reproduce the behavior:

  1. touch repro.lua
  2. paste in
local root = vim.fn.fnamemodify("./repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

local lazypath = root .. "/plugins/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",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
  {
    "nvimdev/dashboard-nvim",
    event = "VimEnter",
    opts = function()
      local opts = {
        theme = "doom",
        config = {
          header = {
            "                                                       ",
            "                                                       ",
            "                                                       ",
            " ███╗   ██╗ ███████╗ ██████╗  ██╗   ██╗ ██╗ ███╗   ███╗",
            " ████╗  ██║ ██╔════╝██╔═══██╗ ██║   ██║ ██║ ████╗ ████║",
            " ██╔██╗ ██║ █████╗  ██║   ██║ ██║   ██║ ██║ ██╔████╔██║",
            " ██║╚██╗██║ ██╔══╝  ██║   ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║",
            " ██║ ╚████║ ███████╗╚██████╔╝  ╚████╔╝  ██║ ██║ ╚═╝ ██║",
            " ╚═╝  ╚═══╝ ╚══════╝ ╚═════╝    ╚═══╝   ╚═╝ ╚═╝     ╚═╝",
            "                                                       ",
            "                                                       ",
            "                                                       ",
            "                                                       ",
          },
          center = {
            {
              icon = "󰈞  ",
              desc = "Find File                              ",
              action = function()
                require("telescope.builtin").find_files()
              end,
              key = "<Leader> p f",
            },
            {
              icon = "󰈢  ",
              desc = "Recently opened files                   ",
              action = function()
                require("telescope.builtin").oldfiles()
              end,
              key = "<Leader> p o",
            },
            {
              icon = "  ",
              desc = "Open Nvim config                        ",
              action = function()
                require("telescope.builtin").find_files({ cwd = vim.fn.expand("~/.config/nvim") })
              end,
              key = "<Leader> e c",
            },
            {
              icon = "  ",
              desc = "New file                                ",
              action = "enew",
              key = "e",
            },
            {
              icon = "󰗼  ",
              desc = "Quit Nvim                               ",
              action = "qa",
              key = "q",
            },
          },
        },
      }
      return opts
    end,
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})
  1. nvim -u repro.lua
  2. run :Dashboard and hit j 2 times, you will see the issue on the "gear" icon and the "one file" icon.

Expected behavior Not moving my cursor further

Screenshots Undesired behavior: image

Desired behavior image (being on the first letter)

Owen000 commented 1 day ago

Interesting note, I found that if I set the very topmost icon (Find File) to  (the gear icon that had the issue) it doesn't break.