Skip to content

Commit 9f493a5

Browse files
committed
Guard against log buf upserting race conditions and nil concats #320
1 parent 3331aa0 commit 9f493a5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

fnl/conjure/log.fnl

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141

4242
(nvim.buf_set_lines
4343
buf 0 -1 false
44-
[(.. (client.get :comment-prefix)
45-
"Sponsored by @"
46-
(a.get sponsors (a.inc (math.floor (a.rand (a.dec (a.count sponsors))))))
47-
" ❤")]))
44+
[(str.join [(client.get :comment-prefix)
45+
"Sponsored by @"
46+
(a.get sponsors (a.inc (math.floor (a.rand (a.dec (a.count sponsors))))))
47+
" ❤"])]))
4848

4949
(defn- upsert-buf []
5050
(buffer.upsert-hidden
5151
(log-buf-name)
52-
on-new-log-buf))
52+
(client.wrap on-new-log-buf)))
5353

5454
(defn clear-close-hud-passive-timer []
5555
(a.update-in state [:hud :timer] timer.destroy))

lua/conjure/log.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ end
4343
_2amodule_2a["log-buf?"] = log_buf_3f
4444
local function on_new_log_buf(buf)
4545
state["jump-to-latest"].mark = nvim.buf_set_extmark(buf, state["jump-to-latest"].ns, 0, 0, {})
46-
return nvim.buf_set_lines(buf, 0, -1, false, {(client.get("comment-prefix") .. "Sponsored by @" .. a.get(sponsors, a.inc(math.floor(a.rand(a.dec(a.count(sponsors)))))) .. " \226\157\164")})
46+
return nvim.buf_set_lines(buf, 0, -1, false, {str.join({client.get("comment-prefix"), "Sponsored by @", a.get(sponsors, a.inc(math.floor(a.rand(a.dec(a.count(sponsors)))))), " \226\157\164"})})
4747
end
4848
_2amodule_locals_2a["on-new-log-buf"] = on_new_log_buf
4949
local function upsert_buf()
50-
return buffer["upsert-hidden"](log_buf_name(), on_new_log_buf)
50+
return buffer["upsert-hidden"](log_buf_name(), client.wrap(on_new_log_buf))
5151
end
5252
_2amodule_locals_2a["upsert-buf"] = upsert_buf
5353
local function clear_close_hud_passive_timer()

0 commit comments

Comments
 (0)