From 619ededcff79e33a7e0ea677881dd07957449f9d Mon Sep 17 00:00:00 2001 From: David van Munster <39461169+dmun@users.noreply.github.com> Date: Sat, 7 May 2022 05:53:33 +0200 Subject: [PATCH] fix: large file lag with filesize component (partially reverts #649) (#675) --- lua/lualine/components/filesize.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/lualine/components/filesize.lua b/lua/lualine/components/filesize.lua index 1b3add3..77f482c 100644 --- a/lua/lualine/components/filesize.lua +++ b/lua/lualine/components/filesize.lua @@ -1,7 +1,14 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. local function filesize() - local size = vim.fn.wordcount().bytes + local file = vim.fn.expand('%:p') + if file == nil or #file == 0 then + return '' + end + local size = vim.fn.getfsize(file) + if size <= 0 then + return '' + end local suffixes = { 'b', 'k', 'm', 'g' }