From 1a8d8240b458a6b82751702bfb217f00eaf305b6 Mon Sep 17 00:00:00 2001 From: Munif Tanjim Date: Sat, 10 Jun 2023 22:59:48 +0600 Subject: [PATCH] feat(line): update types --- lua/nui/line/init.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lua/nui/line/init.lua b/lua/nui/line/init.lua index 0171c810..14aa7137 100644 --- a/lua/nui/line/init.lua +++ b/lua/nui/line/init.lua @@ -1,22 +1,24 @@ local Object = require("nui.object") local NuiText = require("nui.text") local defaults = require("nui.utils").defaults -local is_type = require("nui.utils").is_type ---@class NuiLine ---@field _texts NuiText[] local Line = Object("NuiLine") ----@param texts? table[] NuiText objects +---@param texts? NuiText[] function Line:init(texts) self._texts = defaults(texts, {}) end ---@param content string|NuiText|NuiLine ----@param highlight? string|table data for highlight +---@param highlight? string|nui_text_extmark data for highlight ---@return NuiText|NuiLine function Line:append(content, highlight) - local block = is_type("string", content) and NuiText(content, highlight) or content + local block = content + if type(block) == "string" then + block = NuiText(block, highlight) + end if block._texts then ---@cast block NuiLine for _, text in ipairs(block._texts) do