-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inactive tabs lose their sorting #1852
Comments
Could you please provide a minimal reproducible code for me to tinker with and see if I can make it work? If showing two tabs at the same time is tricky, just printing out the file lists for the different tabs would be enough. |
Of course. This is a minimal plugin that creates two visible tabs and shows the problem:
local view = false
local old_root_layout = nil
local old_root_build = nil
local left
local right
local function entry(state, args)
local action = args[1]
if not action then
return
end
if action == "toggle" then
if not view then
-- Create tabs
left = cx.tabs.idx
right = left
old_root_layout = Root.layout
old_root_build = Root.build
Root.layout = function(root)
root._chunks = ui.Layout()
:direction(ui.Layout.HORIZONTAL)
:constraints({
ui.Constraint.Percentage(50),
ui.Constraint.Percentage(50),
})
:split(root._area)
end
Root.build = function(root)
root._children = {
Tab:new(root._chunks[1], cx.tabs[left]),
Tab:new(root._chunks[2], cx.tabs[right]),
}
end
view = true
else
view = false
left = cx.tabs.idx
right = left
-- Reset UI
Root.layout = old_root_layout
Root.build = old_root_build
end
ya.app_emit("resize", {})
end
if action == "bug" then
ya.manager_emit("tab_create", {})
right = right + 1
end
end
local function setup(state, opts)
end
return {
entry = entry,
setup = setup,
}
[manager]
prepend_keymap = [
{ on = "T", run = "plugin --sync sorting-bug --args=toggle", desc = "Call sorting-bug" },
{ on = "B", run = "plugin --sync sorting-bug --args=bug", desc = "Call sorting-bug" },
]
sort_by = "mtime"
sort_reverse = true
sort_dir_first = false
show_hidden = true
Applying the patch in my original message "fixes" the problem by forcing all the tabs to get their files updated, but I doubt it is the most efficient method. Aside from this, I think there is also a bug when using |
Thanks, I replicated it and made a bit of simplification to the reproducer: local function entry(_, args)
if args[1] == "bug" then
ya.manager_emit("tab_create", {})
return
end
Root.layout = function(root)
root._chunks = ui.Layout()
:direction(ui.Layout.HORIZONTAL)
:constraints({
ui.Constraint.Percentage(50),
ui.Constraint.Percentage(50),
})
:split(root._area)
end
Root.build = function(root)
root._children = {
Tab:new(root._chunks[1], cx.tabs[1]),
Tab:new(root._chunks[2], cx.tabs[#cx.tabs]),
}
end
local redraw = Tab.redraw
Tab.redraw = function(self)
self._base = { ui.Text(string.format("ID: %d; Active: %d", self._tab.id, cx.tabs.idx)):area(self._area) }
return redraw(self)
end
ya.app_emit("resize", {})
end
return { entry = entry } This is a result of the combination of two optimizations:
Yazi always treats the |
Thank you. It is more or less what I was able to figure out by looking at the code. If I follow your advice and do a It seems despite the sorting happening, it then gets discarded as I switch back to the other pane. Thanks a lot. EDITED: I thought switching, sorting and then switching back was working, but it is not. |
Please try #1885 With this PR, you can specify which tab to apply sorting to by: ya.manager_emit('sort', { tab = 1 }) (replace |
Thank you for adding this feature. Unfortunately, as far as I can tell, this doesn't fix the case I was presenting. Maybe the reason is caching seems to have some issues.
|
Will look into it. Reopened |
yazi --debug
outputPlease describe the problem you're trying to solve
This is not a relevant issue in yazi given a regular use. Active tabs are always correctly sorted.
I have a plugin that creates a dual pane configuration, dual-pane.yazi, and the tab shown on the non-active pane loses its sorting in certain cases, like for example when adding a new tab or copying files into it.
Would you be willing to contribute this feature?
Describe the solution you'd like
Going through Yazi's code,
yazi-core/src/manager/commands/update_files.rs:44
applies the file attributes to the active tab:
If tI change his code to apply the file attributes to all the tabs, the "problem" disappears:
I don't claim this is the best solution, or even that a solution is needed, because this only affects a handful of users than want to show more than one tab at the same time, but it would be great if you could help finding a solution that is maybe better than what I am proposing, as I don't know the code very well, and I am sure there are better ways to do this without a noticeable performance hit.
Thank you!
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: