Skip to content

Commit 301262f

Browse files
committed
Run listener in correct buffer on Neovim
1 parent 5938577 commit 301262f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

plugin/strip_trailing_whitespace.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,12 @@ function s:OnBufEnter() abort
197197
if has('nvim')
198198
" Parsing the lua Ex command can fail on broken Vim <8.2.1908 installs
199199
execute 'lua vim.api.nvim_buf_attach(0, false, {
200-
\ on_lines = function(_, bufnr, _, firstline, lastline, new_lastline)
201-
\ vim.api.nvim_call_function("StripTrailingWhitespaceListener", {bufnr, firstline + 1, lastline + 1, new_lastline - lastline,
202-
\ {{lnum = firstline + 1, ["end"] = lastline + 1, added = new_lastline - lastline, col = 1}}})
203-
\ end, })'
200+
\ on_lines = function(_, buf, _, firstline, lastline, new_lastline)
201+
\ local args = {buf, firstline + 1, lastline + 1, new_lastline - lastline,
202+
\ {{lnum = firstline + 1, ["end"] = lastline + 1, added = new_lastline - lastline, col = 1}}}
203+
\ vim.api.nvim_buf_call(buf, function()
204+
\ vim.api.nvim_call_function("StripTrailingWhitespaceListener", args)
205+
\ end) end, })'
204206
else
205207
call listener_add('StripTrailingWhitespaceListener')
206208
endif

0 commit comments

Comments
 (0)