From cdc574c9b0c2803e3d1786f4b6f317782b12fadc Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Mon, 20 Sep 2021 21:47:25 +0600 Subject: [PATCH] fix: nil error with Alpha on buffers component --- README.md | 1 + doc/lualine.txt | 1 + lua/lualine/components/buffers.lua | 9 +++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e39c19..dd9ee54 100644 --- a/README.md +++ b/README.md @@ -385,6 +385,7 @@ sections = { dashboard = 'Dashboard', packer = 'Packer', fzf = 'FZF', + alpha = 'Alpha' }, -- shows specific buffer name for that filetype ( { `filetype` = `buffer_name`, ... } ) buffers_color = { active = nil, -- color for active buffer diff --git a/doc/lualine.txt b/doc/lualine.txt index 5f7d3b9..cf28573 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -364,6 +364,7 @@ Component specific local options ~ dashboard = 'Dashboard', packer = 'Packer', fzf = 'FZF', + alpha = 'Alpha' }, -- shows specific buffer name for that filetype ( { `filetype` = `buffer_name`, ... } ) buffers_color = { active = nil, -- color for active buffer diff --git a/lua/lualine/components/buffers.lua b/lua/lualine/components/buffers.lua index 995e2d1..8bc00bc 100644 --- a/lua/lualine/components/buffers.lua +++ b/lua/lualine/components/buffers.lua @@ -12,6 +12,7 @@ local default_options = { dashboard = 'Dashboard', packer = 'Packer', fzf = 'FZF', + alpha = 'Alpha', }, } @@ -197,12 +198,16 @@ function Buffers:update_status() b.current = true if self.options.self.section < 'lualine_x' then b.last = true - buffers[#buffers].last = nil + if #buffers > 0 then + buffers[#buffers].last = nil + end buffers[#buffers + 1] = b current = #buffers else b.first = true - buffers[1].first = nil + if #buffers > 0 then + buffers[1].first = nil + end table.insert(buffers, 1, b) current = 1 end