Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Next/Previous Todo Comment jumps outside of comments #301

Open
4 tasks done
geoffreylefebvre opened this issue Jul 19, 2024 · 4 comments
Open
4 tasks done

bug: Next/Previous Todo Comment jumps outside of comments #301

geoffreylefebvre opened this issue Jul 19, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@geoffreylefebvre
Copy link

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

  1. Configure todo-comments with a pattern that does not require a colon and comments_only set to true.
  2. Edit Go source file with calls to context.TODO().
  3. 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
  },
})
@geoffreylefebvre geoffreylefebvre added the bug Something isn't working label Jul 19, 2024
geoffreylefebvre added a commit to geoffreylefebvre/todo-comments.nvim that referenced this issue Jul 19, 2024
geoffreylefebvre added a commit to geoffreylefebvre/todo-comments.nvim that referenced this issue Jul 23, 2024
Copy link
Contributor

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.

@github-actions github-actions bot added the stale label Aug 19, 2024
@geoffreylefebvre
Copy link
Author

bump

@github-actions github-actions bot removed the stale label Aug 22, 2024
geoffreylefebvre added a commit to geoffreylefebvre/todo-comments.nvim that referenced this issue Sep 17, 2024
Copy link
Contributor

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.

@github-actions github-actions bot added the stale label Sep 21, 2024
@geoffreylefebvre
Copy link
Author

bump

@github-actions github-actions bot removed the stale label Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant