Skip to content

Commit 1df2325

Browse files
committed
fix(config): fallback invalid ui.path.max_width type
1 parent bbcba06 commit 1df2325

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lua/peekstack/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ end
281281
local function validate_non_negative_number(path, value, default)
282282
if type(value) ~= "number" then
283283
notify.warn(string.format("%s must be a number, got %s", path, type(value)))
284-
return value
284+
return default
285285
end
286286
if value < 0 then
287287
notify.warn(string.format("%s must be >= 0, got %s", path, value))

tests/config_spec.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,18 @@ describe("config", function()
232232
assert.equals(80, cfg.ui.path.max_width)
233233
end)
234234

235+
it("falls back when ui.path.max_width has invalid type", function()
236+
local cfg = config.setup({
237+
ui = {
238+
path = {
239+
max_width = "wide",
240+
},
241+
},
242+
})
243+
assert.is_true(has_message("ui.path.max_width must be a number"))
244+
assert.equals(config.defaults.ui.path.max_width, cfg.ui.path.max_width)
245+
end)
246+
235247
it("falls back on invalid stack view position", function()
236248
local cfg = config.setup({
237249
ui = {

0 commit comments

Comments
 (0)