Skip to content

Conversation

@jakubbortlik
Copy link
Collaborator

This is a followup to #432 that makes sure that if the discussion tree is opened in a right split, the winbar is not just blindly truncated from the left which would hide useful information (number of comments), but individual components of the winbar string are dynamically shortened to fit in the window.

-- Returns the input winbar string shortened to fit into the windo width.
---@return string
local adapt_to_winwidth = function(str)
if too_long(str) then
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The solution is not particularly elegant, but unfortunately, Lua tables do not keep order of insertion, so it's not possible to do simply something like this if we want the winbar to adapt in a predictable way:

local shortenings = {
  ["Inline "] = "".
  [" Mode"] = "",
}
for pattern, replacement in pairs(shortenings) do
  if too_long(str) then
    str:gsub(pattern, replacement)
  end
end

@jakubbortlik jakubbortlik force-pushed the fix-adapt-winbar-string-to-window-width branch from d908881 to 7ae882e Compare December 6, 2024 14:57
@harrisoncramer
Copy link
Owner

Hey Jakub, I actually shortened the winbar quite a bit, so I'm not sure this is still relevant -- if so, you may have to start anew from latest develop.

@harrisoncramer
Copy link
Owner

In fact, you're probably just better off creating a new MR if you want to make changes to the winbar, I'm going to close this one out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants