fix: % in filename not escaped properly.

fixes #579
This commit is contained in:
shadmansaleh 2022-02-15 22:54:29 +06:00
parent 6a3d367449
commit a69251d52b
2 changed files with 13 additions and 0 deletions

View File

@ -2,6 +2,10 @@
-- MIT license, see LICENSE for more details. -- MIT license, see LICENSE for more details.
local M = require('lualine.component'):extend() local M = require('lualine.component'):extend()
local modules = require('lualine_require').lazy_require {
utils = 'lualine.utils.utils',
}
local default_options = { local default_options = {
symbols = { modified = '[+]', readonly = '[-]', unnamed = '[No Name]' }, symbols = { modified = '[+]', readonly = '[-]', unnamed = '[No Name]' },
file_status = true, file_status = true,
@ -44,6 +48,8 @@ M.update_status = function(self)
data = vim.fn.expand('%:t') data = vim.fn.expand('%:t')
end end
data = modules.utils.stl_escape(data)
if data == '' then if data == '' then
data = self.options.symbols.unnamed data = self.options.symbols.unnamed
end end

View File

@ -170,4 +170,11 @@ function M.retry_call_wrap(fn, times)
end end
end end
---Escape % in str so it doesn't get picked as stl item.
---@param str string
---@return string
function M.stl_escape(str)
return str:gsub('%%', '%%%%')
end
return M return M