folke / ts-comments.nvim

Tiny plugin to enhance Neovim's native comments
Apache License 2.0
351 stars 23 forks source link

fix: jsx comment toggling #20

Closed antonk52 closed 5 months ago

antonk52 commented 5 months ago

I noticed that toggling comments in jsx nodes had weird behavior

To repro you create a jsx or tsx file with the following content

export function Comp() {
    return (
        <div>
                <span>hi</span>
        </div>
    )
}

If you place your cursor on <span> and trigger comment toggle gcc results in // %s comment applied instead of expected {/* %s */}.

Turns out nvim_win_get_cursor output and treesitter.get_node's output are off by 1. With this change applied toggling comments on any line for this example file results in the correct comment string applied.

PS: Thanks for the great plugin!

folke commented 5 months ago

Thanks!