From 1ba61c4ba5ee28bb84f04c6fbbbf57f91766b5c6 Mon Sep 17 00:00:00 2001 From: takase1121 <20792268+takase1121@users.noreply.github.com> Date: Thu, 21 Oct 2021 13:29:38 +0800 Subject: fix skipping output if fc-match exits early --- plugins/fontconfig.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/fontconfig.lua b/plugins/fontconfig.lua index 9702422..657e364 100644 --- a/plugins/fontconfig.lua +++ b/plugins/fontconfig.lua @@ -32,18 +32,18 @@ local function resolve_font(spec) }) local prev local lines = {} - while proc:running() do + while true do coroutine.yield(scan_rate) local buf = proc:read_stdout() - if type(buf) == "string" then - local last_line_start = 1 - for line, ln in string.gmatch(buf, "([^\n]-)\n()") do - last_line_start = ln - if prev then line = prev .. line end - table.insert(lines, line) - end - prev = last_line_start < #buf and string.sub(buf, last_line_start) + if not buf then break end + + local last_line_start = 1 + for line, ln in string.gmatch(buf, "([^\n]-)\n()") do + last_line_start = ln + if prev then line = prev .. line end + table.insert(lines, line) end + prev = last_line_start < #buf and string.sub(buf, last_line_start) end if prev then table.insert(lines, prev) end -- cgit v1.2.3