Closed MunifTanjim closed 1 week ago
Can't reproduce it, maybe some script change your hlsearch
.
Okay, I reproduced it like this:
vim.api.nvim_create_autocmd("BufWritePre", {
callback = function()
vim.wait(2000)
end,
})
*
or /
:nohl
:w
vim.wait
is happening, move the cursor (e.g. press j
)Here vim.wait(2000)
is artificially delaying the file save. But in my actual config it happens because of lsp code formatting that runs before the buffer is written.
Sorry, still can't rerpoduce it.
I have the same problem. When I save a file, it shows the lens quickly on every line and then disappears. My config:
require("hlslens").setup()
Nvim version:
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1693350652
I am able to reproduce the issue with the following config:
minimal.lua
vim.env.LAZY_STDPATH = '.repro'
load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))()
vim.api.nvim_create_autocmd("BufWritePre", {
callback = function()
vim.wait(10)
vim.cmd("m +1")
vim.cmd("m -2")
end,
})
require('lazy.minit').repro {
spec = {
{
'kevinhwang91/nvim-hlslens',
config = function()
require('hlslens').setup()
end,
lazy = false,
},
},
}
NVIM v0.10.1 Build type: Release LuaJIT 2.1.1725453128
In order to see the flickering follow these steps:
Create a file and add a couple lines to highlight
main.cpp
int main() {
int foo = 1;
int bar = 2;
int foobar = foo + bar;
return foobar;
}
minimal.lua
configuration with nvim --clean -u minimal.lua main.cpp
:noh
:w
. Repeat this step as it is really inconsistentI worked around the issue with this answer on stackoverflow.
I am able to reproduce the issue with the following config:
minimal.lua
vim.env.LAZY_STDPATH = '.repro' load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))() vim.api.nvim_create_autocmd("BufWritePre", { callback = function() vim.wait(10) vim.cmd("m +1") vim.cmd("m -2") end, }) require('lazy.minit').repro { spec = { { 'kevinhwang91/nvim-hlslens', config = function() require('hlslens').setup() end, lazy = false, }, }, }
NVIM v0.10.1 Build type: Release LuaJIT 2.1.1725453128
In order to see the flickering follow these steps:
- Create a file and add a couple lines to highlight
main.cpp
int main() { int foo = 1; int bar = 2; int foobar = foo + bar; return foobar; }
- Open this file with the
minimal.lua
configuration withnvim --clean -u minimal.lua main.cpp
- Highlight a word. int for example
- Then disable highlight with
:noh
- Save the file with
:w
. Repeat this step as it is really inconsistentI worked around the issue with this answer on stackoverflow.
Fixed.
nvim --version
:Describe the bug A clear and concise description of what the bug is.
To Reproduce using
nvim -u mini.lua
Example:
cat mini.lua
Steps to reproduce the behavior:
*
or/
:nohl
:w
Expected behavior
Saving a file shouldn't cause flicker.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
https://github.com/kevinhwang91/nvim-hlslens/blob/5e3e9088fba7508cee3612ee50b14dfdd3ab19af/lua/hlslens/cmdline/init.lua#L330-L334
The flicker is triggered from this code.