Skip to content

Commit ec39aa1

Browse files
committed
fix(search): defer function to ensure cursor update. Fixes #27
1 parent 911fce9 commit ec39aa1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lua/tiny-glimmer/overwrite/search.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ local animation_group = require("tiny-glimmer.namespace").animation_group
55
local function search(opts, search_pattern)
66
local buf = vim.api.nvim_get_current_buf()
77

8-
vim.schedule(function()
8+
-- Fix for flash.nvim
9+
-- Need to wait for the cursor to be updated, and a simple vim.schedule is still too early
10+
vim.defer_fn(function()
911
local cursor_pos = vim.api.nvim_win_get_cursor(0)
1012
local matches = vim.fn.matchbufline(buf, search_pattern, cursor_pos[1], cursor_pos[1])
1113

@@ -27,7 +29,7 @@ local function search(opts, search_pattern)
2729
range = range,
2830
},
2931
})
30-
end)
32+
end, 5)
3133
end
3234

3335
function M.setup(opts)

0 commit comments

Comments
 (0)