fix component(filename) add separator between filename and icons (#812)
This makes it behave like the default statusline. fixes #794
This commit is contained in:
parent
a03f31f566
commit
5d133a1ef2
|
@ -85,19 +85,21 @@ M.update_status = function(self)
|
||||||
data = shorten_path(data, path_separator, estimated_space_available)
|
data = shorten_path(data, path_separator, estimated_space_available)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local symbols = {}
|
||||||
if self.options.file_status then
|
if self.options.file_status then
|
||||||
if vim.bo.modified then
|
if vim.bo.modified then
|
||||||
data = data .. self.options.symbols.modified
|
table.insert(symbols, self.options.symbols.modified)
|
||||||
end
|
end
|
||||||
if vim.bo.modifiable == false or vim.bo.readonly == true then
|
if vim.bo.modifiable == false or vim.bo.readonly == true then
|
||||||
data = data .. self.options.symbols.readonly
|
table.insert(symbols, self.options.symbols.readonly)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.options.newfile_status and is_new_file() then
|
if self.options.newfile_status and is_new_file() then
|
||||||
data = data .. self.options.symbols.newfile
|
table.insert(symbols, self.options.symbols.newfile)
|
||||||
end
|
end
|
||||||
return data
|
|
||||||
|
return data .. (#symbols > 0 and ' ' .. table.concat(symbols, '') or '')
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -479,12 +479,27 @@ describe('Filename component', function()
|
||||||
assert_component('filename', opts, 'test-file.txt')
|
assert_component('filename', opts, 'test-file.txt')
|
||||||
vim.bo.modified = true
|
vim.bo.modified = true
|
||||||
assert_component('filename', opts, 'test-file.txt [+]')
|
assert_component('filename', opts, 'test-file.txt [+]')
|
||||||
vim.bo.modified = false
|
|
||||||
vim.bo.ro = true
|
vim.bo.ro = true
|
||||||
|
assert_component('filename', opts, 'test-file.txt [+][-]')
|
||||||
|
vim.bo.modified = false
|
||||||
assert_component('filename', opts, 'test-file.txt [-]')
|
assert_component('filename', opts, 'test-file.txt [-]')
|
||||||
vim.cmd(':bdelete!')
|
vim.cmd(':bdelete!')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('can show new_file_status', function ()
|
||||||
|
local opts = build_component_opts {
|
||||||
|
component_separators = { left = '', right = '' },
|
||||||
|
padding = 0,
|
||||||
|
newfile_status = true,
|
||||||
|
path = 0,
|
||||||
|
}
|
||||||
|
vim.cmd(':e new-file.txt')
|
||||||
|
assert_component('filename', opts, 'new-file.txt [New]')
|
||||||
|
vim.bo.modified = true
|
||||||
|
assert_component('filename', opts, 'new-file.txt [+][New]')
|
||||||
|
vim.cmd(':bdelete!')
|
||||||
|
end)
|
||||||
|
|
||||||
it('can show relative path', function()
|
it('can show relative path', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { left = '', right = '' },
|
component_separators = { left = '', right = '' },
|
||||||
|
|
Loading…
Reference in New Issue