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

[mini.files] cursorline is visible in file preview #1391

Closed
3 tasks done
tvsfx opened this issue Dec 10, 2024 · 5 comments
Closed
3 tasks done

[mini.files] cursorline is visible in file preview #1391

tvsfx opened this issue Dec 10, 2024 · 5 comments
Labels
bug Something isn't working mini.files

Comments

@tvsfx
Copy link

tvsfx commented Dec 10, 2024

Contributing guidelines

Module(s)

mini.files

Description

When setting

vim.opt.cursorline = true
vim.opt.cursorlineopt = "line" -- Or "both"
require("mini.files").setup({ windows = { preview = true } })

The file preview will have the cursorline set.
I would turn the cursorline off myself in the MiniFilesWindowOpen handler, but there seems to be no way currently to differentiate between a preview of a file vs. a (preview of a ) directory in mini.files (bar requesting more state from mini.files and/or traversing the filesystem ourselves)

Neovim version

v0.10.2

Steps to reproduce

  1. Use config options above
  2. Open mini.files and navigate to any file so that the preview is shown
  3. The preview will have its cursorline set

Expected behavior

Files do not have the cursorline set, since there is no way to edit them. For buffer previews this is different, since the line is where our cursor will land.

Actual behavior

Cursor line is set.

@tvsfx tvsfx added the bug Something isn't working label Dec 10, 2024
@echasnovski
Copy link
Owner

Thanks for the issue!

Haven't really noticed this myself, but I guess it indeed makes sense to not show cursorline in file previews. I'll take a look.

@echasnovski
Copy link
Owner

This should now be resolved on latest main branch. Thanks again for noticing this!

@tvsfx
Copy link
Author

tvsfx commented Dec 12, 2024

Just tested, and it works intermittently for me now (sometimes there's a cursorline, sometimes there's not). Specifically, there's a cursorline for the first preview in a newly opened folder, and after that, no more cursorline is shown.
I think the following code might be the issue:

mini.nvim/lua/mini/files.lua

Lines 2480 to 2481 in d084df4

-- Make sure that 'cursorline' is not overridden by `config.style`
vim.wo[win_id].cursorline = true

echasnovski added a commit that referenced this issue Dec 12, 2024
Resolve #1391 (hopefully, for real this time)
@echasnovski
Copy link
Owner

Yeah, my bad, didn't interactively test when file is immediately previewed after opening explorer. Should be fixed now.

I think the following code might be the issue:

Only partially, but yes: 'cursorline' was set initially, but did not get unset later due to a big if statement (which should have been a more direct vim.wo[win_id].cursorline = <boolean: path is for directory>.

@tvsfx
Copy link
Author

tvsfx commented Dec 13, 2024

Now it works like a charm, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mini.files
Projects
None yet
Development

No branches or pull requests

2 participants