-
-
Notifications
You must be signed in to change notification settings - Fork 557
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: add option to set the position of the preview window #2064
Conversation
Why are we moving the preview to the top in non-inverted mode? It's been at the bottom ever since it was introduced. I find this change jarring, and am likely not alone there. I think realistically this needs to be configurable and opt in, because I can pretty much guarantee as soon as this is released we will have unhappy users in the issues. Probably a "preview position" or something would make sense, and leave the default as they have been |
I was testing with This means that while you are searching the preview window changes size and the search and result window move up and down. I was very distracted by this behavior and thought it was a bug. And apparently somebody else (Adda in the forum) also thought it was strange and described it as a flickering of the screen. Just to clarify, this has nothing to do with my change I introduced a while back to only show a preview when the command is longer than the terminal width. When using this new option it only makes this behavior stand out even more. I have been verifying my findings by testing with an atuin version (897af9a) before my PR was merged. Here is a video of what I mean (also taken from atuin 897af9a): jump.mp4However, I also understand that people might be shocked and annoyed by this change. I am more than happy to add a setting to make the position configurable. |
I've updated the title and description of this PR. Unfortunately the code is not as pretty as I hoped. The TUI components are a pain and there are not many options to make it more succinct. I set one |
@ellie this one is ready for another review and also I'm more than happy to change it as mentioned in my previous comment. |
3c1bff4
to
0e2a546
Compare
I appreciate you trying to solve this, but given that it's not a particularly high priority issue + that the code here would reduce maintainability of the TUI, I'd rather not proceed. As I've said in previous PRs, even breaking things down a bit to be more legible and testable can be really helpful. Otherwise, Ratatui allows the creation of custom widgets, like our history list |
Understood, although I want to mention a few things: The maintainability of the TUI code is already bad. When writing this PR, it was hard to understand what the code was actually doing due to the lack of comments. Oh, and using My change makes the code longer (4 instead of 2 branches), but I'd argue that the maintainability hasn't changed, since the flow/logic is consistent and no async/channel/trait constructs have been introduced. Also, one can always add more comments. Testing TUI code is always a challenge, otherwise somebody would have done it already. The only tests in this file are the ones that I wrote. I really understand and accept that you don't want to merge PRs you don't agree with, but the current behavior of the TUI is inconsistent. The default behavior after this PR doesn't change that, but at least people can choose where the preview window is. |
You're absolutely correct! That's on me. Previously, I've been too hasty to merge work that focuses too much on new features and too little on improving the health of the codebase. Both my own and that of contributors. Contributions should aim to improve the situation, not compound it. Especially when you've contributed a few times and been around for a while, we should try to enhance maintainability and readability.
In that case, perhaps you could have added a comment explaining it? Or perhaps refactor it to make a bit more sense? Nit picking at the current state of things isn't particularly constructive, and in this case just feels like a bad reaction to my critique and feedback on your work.
Your implementation significantly increases code complexity, requiring Clippy even highlights that as applying to "functions that should be split up into multiple functions", which is feedback I've given you about previous contributions.
I appreciate it! I'd also like to note that those tests weren't there until you were pushed for them in a previous review cycle.
I don't have any issues with the feature, but I do have issues with the implementation. I don't have the time or energy to go through another review cycle where I ask you to improve the quality of the code and have to spell out precisely how.
I don't think this feature is high enough priority, given the lack of many requests from other users and the issues I've mentioned previously. |
You are correct, I should have added a comment. I would have liked to refactor it, but I am not a ratatui person. I wouldn't know how.
This I do not understand. Drawing the line I underatand. It is fine and I accept that. What I don't understand is why clippy throws that warning, since the complexity is not really increased. I was in DB2 development. Having nested structs (up to 12 levels) used with thread synchronization and latching is complex. Adding 2 more branches to a linear workflow is not.
You must have noticed by now that I am not a Rust programmer. I've never learned how to write code in Rust. I understand the basic concepts, but that is all. I wish I had more time to learn Rust properly. I can only say that I would work on a better implementation, if I knew how. This leaves me at hoping for someone to implement this properly. Who knows, maybe someone will. |
This change adds an option to set the position of the preview window.
The default is
bottom
, which is the current behavior.See the forum discussion here.
For this particular TUI change there are no test cases to write. I thought how I could write any, but none of them made any sense.
I tested all variations (compact/invert/preview) manually.
invert = false
invert = true
Checks