fix(filename): include window_width to space estimation & expose
shorting_target option setting shorting target to 0 disables path shorting closes #8 Co-authored-by: NullVoxPopuli <LPSego3+dev@gmail.com>
This commit is contained in:
parent
ee5c56e911
commit
d360039969
|
@ -320,7 +320,9 @@ sections = {
|
|||
{
|
||||
'filename',
|
||||
file_status = true, -- displays file status (readonly status, modified status)
|
||||
path = 0 -- 0 = just filename, 1 = relative path, 2 = absolute path
|
||||
path = 0, -- 0 = just filename, 1 = relative path, 2 = absolute path
|
||||
shorting_target = 40 -- Shortens path to leave 40 space in the window
|
||||
-- for other components. Terrible name any suggestions?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,6 +252,8 @@ Component specific local options~
|
|||
'filename',
|
||||
file_status = true, -- displays file status (readonly status, modified status)
|
||||
path = 0 -- 0 = just filename, 1 = relative path, 2 = absolute path
|
||||
shorting_target = 40 -- Shortens path to leave 40 space in the window
|
||||
-- for other components. Terrible name any suggestions?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ FileName.new = function(self, options, child)
|
|||
new_instance.options.file_status = true
|
||||
end
|
||||
if new_instance.options.path == nil then new_instance.options.path = 0 end
|
||||
if new_instance.options.shorting_target == nil then
|
||||
new_instance.options.shorting_target = 40
|
||||
end
|
||||
|
||||
return new_instance
|
||||
end
|
||||
|
@ -43,12 +46,15 @@ FileName.update_status = function(self)
|
|||
|
||||
if data == '' then data = '[No Name]' end
|
||||
|
||||
local windwidth = vim.fn.winwidth(0)
|
||||
local estimated_space_available = 40
|
||||
local path_separator = package.config:sub(1, 1)
|
||||
for _ = 0, count(data, path_separator) do
|
||||
if windwidth <= 84 or #data > estimated_space_available then
|
||||
data = shorten_path(data, path_separator)
|
||||
if self.options.shorting_target ~= 0 then
|
||||
local windwidth = vim.fn.winwidth(0)
|
||||
local estimated_space_available = windwidth - self.options.shorting_target
|
||||
|
||||
local path_separator = package.config:sub(1, 1)
|
||||
for _ = 0, count(data, path_separator) do
|
||||
if windwidth <= 84 or #data > estimated_space_available then
|
||||
data = shorten_path(data, path_separator)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue