smjonas / live-command.nvim

Easily create previewable commands in Neovim.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strange behavior with macro "dd" when rows are identical

premell opened this issue · comments

So this behavior is kinda hard to explain and i dont fully understand it myself. Basically when saving "dd" to a macro it behaves very weirdly when the text is the same. It starts from the second to last row and goes up. When i changed to only a few rows being the same it started from the last of the similar rows and counted upwards. Once it had finished it started going down as normal

A bonus bug i found is that if you have recorded "dd" to q and then override it (for example i wrote "testing" at the end of the line), the preview will show both the previous macro to delete and the new macro. Although when you click enter the result is as you expect, but the preview is wrong.

Lastly I am sorry that i didnt have screenkey. I couldnt get it to work on fedora wayland :/ You have to take my word that i recorded "dd"

Screencast.from.2023-02-26.17-45-56.webm

this is the minimal example i used (thank god for NVIM_APPNAME)

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)

vim.g.mapleader = " " -- make sure to set `mapleader` before lazy so your mappings are correct

require("lazy").setup({
	{"smjonas/live-command.nvim",
  opts = {
    commands = {
      Norm = { cmd = "norm" },
      Reg = {
        cmd = "norm",
        -- This will transform ":5Reg a" into ":norm 5@a"
        args = function(opts)
          return (opts.count == -1 and "" or opts.count) .. "@" .. opts.args
        end,
        range = "",
      },
    },
}
}
})