kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
3.19k stars 62 forks source link

Neovim crashes when changing tags #10

Closed LeviticusNelson closed 2 years ago

LeviticusNelson commented 2 years ago

Whenever I try to change a tag (cst) my neovim crashes, printing

[1]    49861 segmentation fault lvimund'.utils).NOOP
kylechui commented 2 years ago

Can you update the plugin and see if the latest commit fixes the issue? If not, please give me an example of the buffer you're editing, where your cursor is, and what keystrokes you're using to change the tag. Thanks!

LeviticusNelson commented 2 years ago

It's an HTML File, I think it crashes if you try to change the tag of an element while the cursor is on the child element. Example:

<c-carousel>
    <div> // the cursor would be on the div
    </div>
</c-carousel>
LeviticusNelson commented 2 years ago

I am using cst as the keystroke

kylechui commented 2 years ago

Unfortunately I'm unable to replicate this, I've copy-pasted your HTML into my own test file, and have run cst while the cursor is on the div (in varying locations as well), and can't seem to crash Neovim. Have you updated the plugin to the latest commit?

LeviticusNelson commented 2 years ago

Yes I have

kylechui commented 2 years ago

Maybe try to uninstall/reinstall the plugin; I'll try to reproduce it using a minimal config when I have the time later

LeviticusNelson commented 2 years ago

Try this:

<c-carousel>
        <div for:each={results} for:item="result" key={result.Id}> // cursor on this div
            <c-hero-carousel-image
                src={result.ImageURL}
                href={result.href}
                title={result.Title__c}
                body={result.Body_Text__c}
            >
            </c-hero-carousel-image>
        </div>
    </c-carousel>
kylechui commented 2 years ago

I've just tried that exact test file with the following config:

---@diagnostic disable: undefined-global

return require("packer").startup(function()
    use({
        "kylechui/nvim-surround",
        config = function()
            require("nvim-surround").setup({})
        end,
    })
end)

but I still can't reproduce the issue. I'm able to change the tag contents/delete them just fine (with the exception of the inner c-hero-carousel-image tag, but that's because I forgot that dashes are valid characters in tag types).

andrewferrier commented 2 years ago

For what it's worth, I see a very similar issue (perhaps the same one), but using the deletion keybinding. Reproduction:

    use({ "x/y" })
    use({ "a/b" })

    use({
        "d/f",
        requires = { "q/r" },
    })

Clearly NeoVim shouldn't crash, so that may be/is an issue with NeoVim itself. But probably nvim-surround is "provoking" it by asking the API for something invalid. Hopefully the above helps narrow down the issue.

kylechui commented 2 years ago

@andrewferrier Do you mind doing me a favor and testing on the latest commit in fix-keymaps? For the record, I wasn't able to reproduce the issue on the latest commit in main either; both deletions worked fine for me.

Edit: fix-keymaps has been merged into main, so the latest commit there should suffice as well.

andrewferrier commented 2 years ago

Yep, the latest main seems to fix the issue for me! Thanks.

kylechui commented 2 years ago

I'll be marking this issue as completed for now then, feel free to re-open in case things change