Skip to content

Commit 4339e5e

Browse files
committed
fix: add default value for stats
1 parent c114f0d commit 4339e5e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

plugin/ccusage.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ local function get_log_level(context)
99
return vim.log.levels.INFO
1010
end
1111

12-
local stats = context.stats
12+
local stats = context.stats or {}
1313

1414
if stats.usage_ratio > 1.0 then
1515
return vim.log.levels.ERROR
@@ -28,7 +28,7 @@ local function get_title(context)
2828
return "CCUsage"
2929
end
3030

31-
local stats = context.stats
31+
local stats = context.stats or {}
3232

3333
if stats.usage_ratio > 1.0 or stats.usage_ratio >= 0.8 then
3434
return "CCUsage Warning"
@@ -62,7 +62,7 @@ local function status_cmd()
6262
end
6363

6464
-- Format the data using the verbose formatter
65-
local formatted_message = verbose_formatter.format(context)
65+
local formatted_message = verbose_formatter(context)
6666
if not formatted_message then
6767
vim.notify("Unable to format usage statistics", vim.log.levels.WARN, {
6868
title = "CCUsage",

0 commit comments

Comments
 (0)