fix(compiler): respect provider open config in M.open() (#23)
* fix(reload): bind SSE server to port 0 for OS-assigned port Problem: the SSE reload server hardcoded port 5554, causing silent failure when that port was already in use. bind() would fail but its return value was never checked; listen() would also error and silently drop via the if err then return end guard. inject() still wrote the dead EventSource URL into the HTML, so the browser would connect to whatever was on 5554 — or nothing — and live reload would silently stop working. Solution: bind to port or 0 so the OS assigns a free port, then call getsockname() after bind to capture the actual port into actual_port. inject() reads actual_port in preference to the hardcoded constant, and stop() resets it. PORT = 5554 is kept only as a last-resort fallback in inject() if actual_port is unset. * fix(compiler): resolve output into ctx before evaluating clean command Problem: M.clean() passes the raw ctx (no output field) to the provider's clean function. Built-in presets work around this by recomputing the output path inline, but custom providers using ctx.output in their clean function receive nil. Solution: resolve output_file from provider.output before eval, extend ctx into resolved_ctx with the output field, and use resolved_ctx when evaluating clean and cwd — consistent with how M.compile() handles args.
This commit is contained in:
parent
e661ea78e8
commit
ec922a3564
1 changed files with 9 additions and 3 deletions
|
|
@ -396,10 +396,16 @@ function M.clean(bufnr, name, provider, ctx)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local cmd = eval_list(provider.clean, ctx)
|
local output_file = ''
|
||||||
local cwd = ctx.root
|
if provider.output then
|
||||||
|
output_file = eval_string(provider.output, ctx)
|
||||||
|
end
|
||||||
|
local resolved_ctx = vim.tbl_extend('force', ctx, { output = output_file })
|
||||||
|
|
||||||
|
local cmd = eval_list(provider.clean, resolved_ctx)
|
||||||
|
local cwd = resolved_ctx.root
|
||||||
if provider.cwd then
|
if provider.cwd then
|
||||||
cwd = eval_string(provider.cwd, ctx)
|
cwd = eval_string(provider.cwd, resolved_ctx)
|
||||||
end
|
end
|
||||||
|
|
||||||
log.dbg('cleaning buffer %d with provider "%s": %s', bufnr, name, table.concat(cmd, ' '))
|
log.dbg('cleaning buffer %d with provider "%s": %s', bufnr, name, table.concat(cmd, ' '))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue