Closed doubleloop closed 2 years ago
I came here because I was having the same issue, but I think it might be better solved like this instead of using pcall:
elseif api.nvim_buf_is_valid(buf) then
api.nvim_buf_set_var(buf, 'autosave_' .. name, value)
end
@danielfalk
I am not a specialist on vim buffer but can there be race condition? I mean can buffer become invalid between calling nvim_buf_is_valid
and api.nvim_buf_set_var
? If no then your approach may be better, if yes, then pcall is better.
Also note that pcall
is already used in similar case so it might be more consistent to use it
@danielfalk I am not a specialist on vim buffer but can there be race condition? I mean can buffer become invalid between calling
nvim_buf_is_valid
andapi.nvim_buf_set_var
? If no then your approach may be better, if yes, then pcall is better.Also note that
pcall
is already used in similar case so it might be more consistent to use it
Neither am I! Just a suggestion because as far as I know, this isn't multi-threaded and the code runs synchronously, but I don't know for sure.