Skip to content

Commit 4c1ac17

Browse files
author
Jose Alvarez
committed
fix(helpers): fix ignore_errors override for formatters
1 parent 0e21241 commit 4c1ac17

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lua/null-ls/helpers.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ M.generator_factory = function(opts)
126126
end
127127

128128
M.formatter_factory = function(opts)
129-
opts.ignore_errors = true
129+
if opts.ignore_errors == nil then opts.ignore_errors = true end
130130
opts.on_output = function(params, done)
131131
local output = params.output
132132
if not output then return done() end

test/spec/helpers_spec.lua

+13-2
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,12 @@ describe("helpers", function()
261261
end)
262262

263263
describe("formatter_factory", function()
264-
local opts = {key = "val"}
264+
local opts
265+
before_each(function()
266+
stub(helpers, "generator_factory")
267+
opts = {key = "val"}
268+
end)
265269

266-
before_each(function() stub(helpers, "generator_factory") end)
267270
after_each(function()
268271
helpers.generator_factory:clear()
269272
helpers.generator_factory:revert()
@@ -278,6 +281,14 @@ describe("helpers", function()
278281
assert.truthy(helpers.generator_factory.calls[1].refs[1].on_output)
279282
end)
280283

284+
it("should not set ignore_errors when already set", function()
285+
opts.ignore_errors = false
286+
helpers.formatter_factory(opts)
287+
288+
assert.equals(helpers.generator_factory.calls[1].refs[1]
289+
.ignore_errors, false)
290+
end)
291+
281292
describe("on_output", function()
282293
local formatter_done = stub.new()
283294
after_each(function() formatter_done:clear() end)

0 commit comments

Comments
 (0)