Skip to content

Commit ebbd7d0

Browse files
Copilotsand4rt
andcommitted
fix: add nil fallback in get_main_width and fix width type annotation
Agent-Logs-Url: https://github.com/sand4rt/zen.nvim/sessions/776df3ec-ea1f-48b9-96ac-c13025ddf517 Co-authored-by: sand4rt <17591696+sand4rt@users.noreply.github.com>
1 parent de7d39f commit ebbd7d0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lua/zen/init.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
--- @field filetype Filetype
55

66
--- @class Config
7-
--- @field main? { width?: number | fun(): number; }
7+
--- @field main? { width: number | fun(): number; }
88
--- @field top? Integration[]
99
--- @field right? { min_width?: number; [number]: Integration[]}
1010
--- @field bottom? Integration[]
@@ -17,9 +17,10 @@
1717
--- @field bottom Integration[]
1818
--- @field left { min_width: number; [number]: Integration[]}
1919

20+
local default_width = 148
2021
--- @type ConfigOptions
2122
local opts = {
22-
main = { width = 148 },
23+
main = { width = default_width },
2324
top = {},
2425
right = { min_width = 46 },
2526
bottom = {},
@@ -32,9 +33,12 @@ local state = {
3233
--- Resolves the configured main width.
3334
---@return number
3435
local function get_main_width()
35-
local width = opts.main.width
36+
local width = opts.main and opts.main.width
3637
if type(width) == "function" then
37-
return width()
38+
width = width()
39+
end
40+
if type(width) ~= "number" then
41+
return default_width
3842
end
3943
return width
4044
end

0 commit comments

Comments
 (0)