Skip to content

Visual surround: selection disappears when using number toggle plugin #315

Description

@simonmandlik

Checklist

  • Have you tried updating the plugin to the latest version?
  • Have you checked the Breaking Changes issue?
  • Have you read through :h nvim-surround to see if there might be any relevant information there?

Neovim Version

NVIM v0.10.0-dev-2274+g1d5f86f69-Homebrew

Plugin Version

Tagged (Stable)

Minimal Configuration

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 = {
    {
        "kylechui/nvim-surround",
        version = "*", -- Use for stability; omit to use `main` branch for the latest features
        config = function()
            require("nvim-surround").setup {}
        end
    },
}

require("lazy").setup(plugins, { root = root .. "/plugins", })

vim.o.number = true

-- from https://github.com/sitiom/nvim-numbertoggle/blob/main/plugin/numbertoggle.lua
local augroup = vim.api.nvim_create_augroup("numbertoggle", {})

vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "CmdlineLeave", "WinEnter" }, {
   pattern = "*",
   group = augroup,
   callback = function()
      if vim.o.nu and vim.api.nvim_get_mode().mode ~= "i" then
         vim.opt.relativenumber = true
      end
   end,
})

vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "CmdlineEnter", "WinLeave" }, {
   pattern = "*",
   group = augroup,
   callback = function()
      if vim.o.nu then
         vim.opt.relativenumber = false
         vim.cmd "redraw"
      end
   end,
})

Sample Buffer

test test
test test

Keystroke Sequence

ejS

Expected behavior

This is what happens after I comment out everything after line 23 in the setup:

image

Actual behavior

image

Additional context

The surrounding still works, this is only a visual issue in the "pending" phase.

The code is from https://github.com/sitiom/nvim-numbertoggle/blob/main/plugin/numbertoggle.lua, but I copied it for easier reproduction

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions