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: When the cursor is on the foldable(group)-item before closing trouble, the restore config fails to work. #540

Closed
3 tasks done
NGPONG opened this issue Jul 11, 2024 · 2 comments
Labels
bug Something isn't working stale

Comments

@NGPONG
Copy link

NGPONG commented Jul 11, 2024

Did you check docs and existing issues?

  • I have read all the trouble.nvim docs
  • I have searched the existing issues of trouble.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

lastest

Operating system/version

linux

Describe the bug

I believe I have identified the cause; it seems to be due to this condition failing.

local cursor = vim.api.nvim_win_get_cursor(self.win.win)
local item_row ---@type number?
if loc.node then
for row, l in pairs(self.renderer._locations) do
if loc.node:is(l.node) then
item_row = row
break
end
end
end

if self.group ~= other.group then
return false
end

After modifying it this way, it works correctly.

function M:is(other)
  if not other then
    return false
  end

  if self == other then
    return true
  end

  if self.id ~= other.id then
    return false
  end

- if self.group ~= other.group then
+ if not vim.deep_equal(self.group, other.group) then
    return false
  end

  if self.group then
    return true
  end
  assert(self.item, "missing item")

  if not other.item then
    return false
  end

  if self.item == other.item then
    return true
  end

  return self.item.id and (self.item.id == other.item.id)
end

However, I'm unsure if this is the intended behavior, so I need to seek more information. In any case, to better illustrate the issue, I have recorded a video.

2024-07-11.234051.mp4

Best regards!

Steps To Reproduce

see above

Expected Behavior

see above

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
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)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  { "folke/trouble.nvim", opts = {} },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@NGPONG NGPONG added the bug Something isn't working label Jul 11, 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 11, 2024
Copy link
Contributor

This issue was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 19, 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 stale
Projects
None yet
Development

No branches or pull requests

1 participant