-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat(fzf): allow fzf win_configs to contain functions, fix vertical offsets #131
Conversation
Thanks! It is not clear to me what is the exact bug and how to reproduce it. EDIT: In addition could you explain how it works and what problem it addresses? I tried to understand but the logic seems a bit twisted. EDIT 2: Also observed that the offset of fzf window is wrong when border is 'single' (not introduced by this PR): Could we fix it in this PR too? |
Essentially, the fzf menu uses relative=win, so with anchor the position can be off by a few cells depending on the border and can end up overlapping the menu (covering entries). This fixes the vertical overlap and ensures the fzf menu is always just a small bar at the bottom.
Sure! That's exactly the issue I was trying to fix (some other cases of it as well). It was overlapping vertically on some occasions, that's what I've fixed so far. I'll look into the horizontal position now. |
I'll try to provide a video or something later but honestly this one is hard to explain lol. It happens with certain scroll positions, when the menu opens above the cursor only. |
@willothy The misalignment should be fixed now, can you confirm? |
Partially, but there are still the header cases to handle. I'll update this PR. |
Why the header will affect the alignment? |
@willothy Do you mean the header of the fzf window? |
Yeah, it can inherit a header from the parent window. I will update this PR to only fix that and remove the things you fixed. |
d5b5c5a
to
e701600
Compare
Should be good now |
@willothy I cannot reproduce the bug where the menu is overlapped with the title/header of the fzf window using the script below, with vim.ui.select({ "tabs", "spaces" }, {
prompt = "Select tabs or spaces:",
format_item = function(item)
return "I'd like to choose " .. item
end,
}, function() end)
However, I can observe that the fzf window has an improperly thick top border because it inherits the border from the select menu ( Can we just merge |
It can occur both ways, either with overlap or the thick border, depending on factors I have not yet determined. I will see if your new commits have fixed it on my end. |
Ok I now don't have the overlap issue, but I do have the thick border issue. |
I don't think so, because then it would break some configs that use borders. I think the complex checks are kinda needed here tbh. Not 100% sure though, I'm testing the idea right now. Have just not found a solution that works for all edge cases. |
Why does it break configs for borders given that |
Because those can be fzf-specific I think. Honestly I'm not sure. But without self._win_configs.border the border doesn't inherit properly. I am looking into it to provide a more specific repro, sorry for not explaining well lol |
Emm I think the border of the menu is calculated from To make it clearer:
For example, we will change the original border config to add a thick upper border if a header is provided to the ui-select function but |
Sounds good, I will keep trying different configurations of this. |
I am struggling to implement something that works with all three of (1) full borders provided by name, (2) full borders provided by array and (3) partial borders provided by array. I can get either partial borders or full borders to work but not both lol |
@willothy You can leave it to me if you find it hard to implement. I will give it a closer look later. |
I think I'll be able to do it (feel free to have a look though),I am just not sure how the fzf window can inherit the parent window's border without having the thick header, unless we manually remove the header or add a hack just for the ui-select implementation which I don't think is ideal. Using self.opts.win_configs has the same issue because the header is defined in self.opts.win_configs. |
6ad710d
to
66b9661
Compare
This seems to work well, it is a mix of your idea and removing the top border when possible. |
Actually, maybe we should leave the border alone since the border for the fzf window is already configurable separately from the menu, so if the users would like to get rid of the thicker header they can. We can also update the defaults so that the fzf menu does not have a thick header by default. Thoughts? |
101d73a
to
38f222f
Compare
@willothy Is this ready to merge? |
I think so, yeah. I've been using my fork with it for a week or so Edit: nevermind, do not merge - found a bug lol |
Might be worth making sure it works for you too tho if you haven't tested the latest version :) |
Agh it behaves differently in the ui-select menu vs the winbar dropdowns. I'll try to finish this up tomorrow. |
fix(fzf): vertical offset for border refactor(fzf): move `win_config` elements into default config
38f222f
to
e21206b
Compare
Ok I've fixed the issues I found, I think this is ready for merge. There are still some edge cases, but none that weren't present before afaik. Just things like different borders between fzf and the menu:
imo those are obscure use cases and can be fixed in followups. But if you want me to work out the width things in this PR I can. |
Nvm, fixing the widths was pretty trivial so everything seems to be working now. It does require potentially evaluating the fzf window border twice, but I don't think that's a huge deal. |
@willothy I have the following error on
Code snippet used to open the ui-select menu (same as the example in vim.ui.select({ "tabs", "spaces" }, {
prompt = "Select tabs or spaces:",
format_item = function(item)
return "I'd like to choose " .. item
end,
}, function(choice)
if choice == "spaces" then
vim.o.expandtab = true
else
vim.o.expandtab = false
end
end) config: require('dropbar').setup({
menu = {
scrollbar = { background = false },
win_configs = {
border = { '', '', '', '' },
}
},
})
vim.ui.select = require('dropbar.utils.menu').select |
Hmm interesting, let me check that out. Edit: too many ternaries haha I will fix that now. |
Alright, I think it should work now |
@willothy fzf window sticking out |
Ahhhh ok just a sec. I think that's specific to ui-select. |
Ah figured it out. I was confused about how nvim handled 4-char borders. |
Sorry for the confusion, just lots of edge cases here haha. I think it should work now, hopfully I'm not wrong again lol |
Yeah it's annoying. I think we could simplify the logic by expanding table-valued border whose length is less than 8 to the equivalent border table with 8 elements first then change the borders in different conditions. It can be a utils function in But let's merge this first. |
Yeah, that would definitely make things simpler, as would utilities so we're not repeating any of this border code anywhere. |
This PR fixes the issue with fzf placement I mentioned in #123.