bug: Next/Previous Todo Comment jumps outside of comments
geoffreylefebvre opened this issue · 9 comments
Did you check docs and existing issues?
- I have read all the todo-comments.nvim docs
- I have updated the plugin to the latest version before submitting this issue
- I have searched the existing issues of todo-comments.nvim
- I have searched the existing issues of plugins related to this issue
Neovim version (nvim -v)
0.10.0
Operating system/version
MacOS 12.7.5
Describe the bug
When navigating a file containing KEYWORDS outside of comments, next/prev todo comments jumps to these even if the buffer has treesitter support and todo-comments is configured with comments_only. This issue happens with Go code which contains context.TODO(), and todo-comments using a pattern that does not require a colon.
I think the problem is that is_comment() in highlight.lua returns true or nil, and the caller in jump.lua explicitly checks for false.
A solution would be for is_comment to return false when the buffer has treesitter support and the match is outside of a comment, or for the caller to test against ~= true instead of == false.
Steps To Reproduce
- Configure todo-comments with a pattern that does not require a colon and comments_only set to true.
- Edit Go source file with calls to context.TODO().
- Navigate through todo comments using next/prev todo comments (i.e ]-t. [-t using LazyVim default bindings).
Expected Behavior
next/prev todo comments should not jump to context.TODO() (or any of the KEYWORDS) outside comments.
Repro
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
{ "folke/todo-comments.nvim",
opts = {
highlight = {
pattern = [[.*<(KEYWORDS)>]],
comments_only = true },
},
},
},
-- add any other plugins here
},
})
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
bump
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
bump
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
bump