Skip to content

Commit

Permalink
fix(range): always apply matchadd
Browse files Browse the repository at this point in the history
Fixes: #70
  • Loading branch information
gbprod committed Oct 9, 2023
1 parent 49f6f49 commit 59628ef
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lua/substitute/range.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ local function create_match(c)
range.clear_match()
range.state.match = vim.fn.matchadd("SubstituteRange", get_escaped_subject(c), 2)

range.state.augroup = vim.api.nvim_create_augroup("SubstituteClearMatch", { clear = true })
vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave", "BufLeave", "CursorMoved" }, {
group = range.state.augroup,
pattern = "*",
callback = range.clear_match,
})
vim.schedule_wrap(function()
range.state.augroup = vim.api.nvim_create_augroup("SubstituteClearMatch", { clear = true })
vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave", "BufLeave", "CursorMoved" }, {
group = range.state.augroup,
pattern = "*",
callback = range.clear_match,
})
end)
end

function range.operator(options)
Expand Down

0 comments on commit 59628ef

Please sign in to comment.