-
-
Notifications
You must be signed in to change notification settings - Fork 685
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
Open pane scrollback in default editor #1403
Comments
@cosminadrianpopescu - you mentioned you might like to work on this. I wanted to open this as a separate issue because it's part of our roadmap. |
Yes, I would like to work on this. |
How would I go about it? What is the idea? How do I replace the content of the pane with a command without putting that command in the history of the current pane's shell? Also, when running the command, is there something to know about it regarding different operating systems? My idea would be to create a new temporary pane which would replace the current one. Is there a better approach? If this is the right approach, how do I know when this temporary panel is closed, to react and put back the old pane? Any hints? |
I think the basic approach should be:
Makes sense? Shall I go into more details about specific sections? A lot of the questions you asked are already handled by the app itself as you can see above. It's just a question of knowing where to look. And since this is a bit of an involved (and in need of refactoring) app, I'm happy to guide you as closely as you'd like me to :) |
Ok. I will have a look and see what I can come up to. I will ask more specific questions when I will arrive at a certain point that I can't handle myself. Thank you. |
Hey @cosminadrianpopescu - sorry to press on this, I just want to release this feature with the next release in ~1 week. Do you think you can see it to completion, or are you too busy? |
I am planning to work on this from Wednesday. I hope to finish it until Sunday. I will keep you updated. I looked already at it. It seems straight forward what you described. What I'm most worried is sending those information back and forth when I want to see what panel is opened (points 5 and 7 in your tutorial). I remember the difficulties I've had in the test case of the editor dump feature. Other than this, it should be straight forward and I should be able to finish it until Sunday. |
Sounds great, thanks for the quick response! If you have trouble, I'm also happy to work on this together. You can also give me a ping on Discord if you like. |
I am at step 6 and having some issues. So far, what I've come up with is this: ScreenInstruction::OpenInPlaceEditor(pid, file_name, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
if let Some(pane1) = active_tab.get_active_pane(client_id) {
scrollbacks.insert(file_name, pane1.pid());
let geom = pane1.current_geom().clone();
active_tab.new_pane(pid, Some(client_id));
if let Some(pane2) = active_tab.get_active_pane_mut(client_id) {
pane2.set_geom(geom);
}
else {
log::error!("New editor pane not found. Maybe there is an issue with launching it?: {:?}", client_id);
}
}
} else {
log::error!("Active tab not found for client id: {:?}", client_id);
}
screen
.bus
.senders
.send_to_server(ServerInstruction::UnblockInputThread)
.unwrap();
screen.update_tabs();
screen.render();
} I have 2 issues:
|
If it's the first option, it's probably that we need to update the pty about the size change. Like we do in this macro: https://github.com/zellij-org/zellij/blob/main/zellij-server/src/tab/mod.rs#L47-L59 (though it will probably be best to do this as part of the original message exchange, since in this case we already know the size - will save a roundtrip). If it's the second option, my guess is that the updated geom is somewhat wrong. If you log it (eg. with log::info or your favorite debugging method), does it show the half or the full geometry?
|
The frame fills up the whole space, but just the editor takes up half. The issues is that the geometry is always the same. So: ScreenInstruction::OpenInPlaceEditor(pid, file_name, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
if let Some(pane1) = active_tab.get_active_pane(client_id) {
scrollbacks.insert(file_name, pane1.pid());
let geom = pane1.current_geom().clone();
log::error!("GEOM is: {:?}, {:?}, {:?}, {:?}", geom.x, geom.y, geom.rows.inner, geom.cols.inner);
active_tab.new_pane(pid, Some(client_id));
if let Some(pane2) = active_tab.get_active_pane_mut(client_id) {
log::error!("NOW GEOM is: {:?}, {:?}, {:?}, {:?}", geom.x, geom.y, geom.rows.inner, geom.cols.inner);
pane2.set_geom(geom);
}
else {
log::error!("NOT Found pane 2 : {:?}", pid);
}
}
} else {
log::error!("Active tab not found for client id: {:?}", client_id);
}
screen
.bus
.senders
.send_to_server(ServerInstruction::UnblockInputThread)
.unwrap();
screen.update_tabs();
screen.render(); So, if I do this, I always get the same geometry:
What is even stranger is that if I do this:
You notice that I'm not even opening the second pane. The geometry is still the same:
So, I'm a little bit confused. |
My guess then is that this is a case of the editor not knowing what size it should take up. Not sure why it takes up exactly half, but we essentially need to make sure a SIGWINCH is sent to it. Have you tried using the |
I'm trying to use |
You can use this unwieldy method: https://github.com/zellij-org/zellij/blob/main/zellij-server/src/screen.rs#L598 |
Trying this and I'm getting again issues with borrowing variables:
|
Finally fixed and now it's fine. :) The panel has the proper size. So, I will continue with the next steps. Thank you. |
So, now for point 7:
How do I know when the panel is closed? |
When a pane is closed (either through a Zellij shortcut or by the program running inside the pane itself) it eventually bubbles down to here: https://github.com/zellij-org/zellij/blob/main/zellij-server/src/tab/mod.rs#L1348 |
For floating panes it seems to work perfectly. However, there are multiple issues with the geometry when it comes to tiled panes. First approach was to save the original geometry and then to restore it in Initially, I get this layout.
Then I select the second pane (Pane 2). There I do
Im am thinking of using some strategy like when a panels is toggled as floating. But even then, probably that if I close the pane opening, then the Also, can we create a new pane without any geometry? Another strategy that I was thinking about was to try to somehow put it in the Any ideas? |
I agree we should not be using the new_pane method. The geometry is set in the The I think we need to use a new method in |
I'll look into it.
This new method should replace which call?
Yes, I took care of this. As I was saying, for floating panes it seems to be working without issues. I imagine that this is because when we have floating panes, inserting a new pane does not impact the geometry of others. |
The |
So far, I have this: pub fn create_pane(&mut self, pid: PaneId, client_id: Option<ClientId>, geom: PaneGeom) {
if self.floating_panes.panes_are_visible() {
self.new_pane(pid, client_id);
} else {
if self.tiled_panes.fullscreen_is_active() {
self.tiled_panes.unset_fullscreen();
}
if let PaneId::Terminal(term_pid) = pid {
let next_terminal_position = self.get_next_terminal_position();
let new_terminal = TerminalPane::new(
term_pid,
geom, // the initial size will be set later
self.style,
next_terminal_position,
String::new(),
self.link_handler.clone(),
self.character_cell_size.clone(),
self.terminal_emulator_colors.clone(),
);
self.tiled_panes.add_pane_with_existing_geom(pid, Box::new(new_terminal));
// self.tiled_panes.insert_pane(pid, Box::new(new_terminal));
// self.should_clear_display_before_rendering = true;
if let Some(client_id) = client_id {
self.tiled_panes.focus_pane(pid, client_id);
}
}
}
} This works better. There are however still issues: some crashes that I need to |
Uff. This has other issues. If I create a pane down, I switch to the panel on the bottom, I replace with the editor, then I switch to the first panel (on top) and close it, the geometry of the panel with the buffer being edited is messed up. |
Want to upload the code to a fork somewhere and I'll take a look? (granted though, I need to leave the house in ~1 hour, so might only get to it tomorrow) |
So, what I would expect would be this:
The output of the pane is this:
Then, I launch Then, I add another pane and do Then I go back to the pane where the buffer is edited and I close the editor. I would expect now to see on the screen
But I only see the first line. More, then if I go again to a new pane and do `echo "file content line 3" >> /tmp/file, I would expect to see on the screen
But what I actually see is
that is actually wrong. So, do you think that my strategy could solve this issue? |
I had another 2 commits, one reverting the previous one and another one implementing the strategy I mentioned. It works perfectly now for tiled_panes (meaning it's not losing any content) but for floating panes only issue 1 is solved (you can't scroll through the pane). The second issue is not yet solved, althought I don't understand why. If you open a floating pane, edit the buffer and then you embed it and then you close it, it will not be replaced by the old panel. The old panel you can retrieve it by showing again the floating panes. What am I missing? Because normally, the pane being already in the tiled_panes and getting the geometry of the editor pane, it should be displayed in it's place, right? |
Hey @cosminadrianpopescu - sorry for not responding, fell asleep quite early. I know you're busy today, but if I could grab just a few moments on your time to help me out, could you:
|
Found the problem. Although the pane is embedded, the |
So, what do you advise? I should go back to commit I will open the PR. |
But before opening the PR, let me know how do you want me to open? Where it is now or at the commit |
Open it where it is now. I'll take a look at this strategy and only change it if there's a need. I'm a little worried that it's a bit complex (I know I'll forget why we did this in 2 months :) ) - but let's see. |
Just pushed my fixes from yesterday. These:
Going to take a look at your changes now, see what needs to be fixed, then write tests, do some cleanup and we're good I think (unless I'm forgetting something). |
PR opened. The only minor issues I see are those I've told you about plus another one, also with floating panes. If you open a floating pane, you then edit the scroll buffer, then you embed and then you make float again, you will see both of the panes. This is again, because of What do you think? |
Hum... does this happen with a regular non-embedded editor pane? I don't fully have context on this yet. Just diving in now to your changes. Can we sum up the issues that we have with the current implementation? |
So, far there are 2 minor issues, in my oppinion:
Unfortunatelly I don't have discord or any other social app (WhatsApp, Teams etc.). I only have signal messenger. If you want, you can send me a private message at |
If you don't have signal messenger, I have my own infrastructure at |
Hey @cosminadrianpopescu - I pushed changes into the branch that should fix everything. I hope you don't mind, but I ended up using the This fixed all the bugs you mentioned - including the one with new info coming to the suppressed terminal (eg. with tail). But please check me to make sure I'm not mistaken (when you have the time). I'm taking a lunch break and afterwards I'm going to write tests and maybe look into placing an editor command override in the config as you suggested (if it won't take too long). I can wait until tomorrow to merge this if you don't have time to test today. |
No, of course. Whatever works best and faster.
I will check out a little bit later. Right now I'm not at a computer. |
All works perfect now (floating and tiled panes). I did not find any new issues. I will keep testing and starting Tuesday, I will use it also in a prod like environment (I will build the new version at work) and let you know if I found more issues (I hope not). I was thinking of one last nice touch. To name the panel rather than "Panel #", maybe we can give it a nice name, like "Edit Panel #" which would then be the number of the panel edited? Or if the panel edited has a given name, then it would be "Edit Panel Custom Name". How difficult would that be? I might be able to give it one hour this evening later. Do you think is fesable? Or better to leave it for later? |
Nice! I plan on releasing either tomorrow or on Tuesday, so you can already use the release version and if there's a bug we can always release a patch. I like the title idea. I'd call it "Editing Pane # Scrollback" |
You might need to update some snapshots since I already added tests, but shouldn't be too difficult with |
I will give it a try and let you know if I can come up with anything. If not, I suppose I can add it at a later stage after release, right? Since today I'm not that free. |
For sure, no stress! As you said, it's a pretty amazing feature as is. I'm very much looking forward to using this in my day-to-day. |
Alright, all is done in the PR.
I also merged from main. So @cosminadrianpopescu - if you want to add the window title sometime tonight, please do go ahead. Otherwise I'll merge this to main tomorrow and release either tomorrow or on Tuesday. |
No, unfortunately I didn't had any time this evening. I'll add that with other release. |
If the scrollback_editor option or $ echo $EDITOR
vim -u ~/.config/vim/vimrc.vim scrollback_editor: '/usr/bin/less --use-color ' |
@nlvw I think we were really counting on this just being a path to a command. I'm not sure this is the "intended" behaviour or not, tbh :) Does it work if you wrap it all in bash script to get the flags? |
I've had the same issue as @nlvw and I can confirm that it works if you wrap it in a script and point the |
Question is... is this a bug or the intended behaviour? I wonder if eg. git picks up the $EDITOR flags when editing merge commits and rebases... |
I found a problem with the current implementation of the feature: If you have several split panes, then you full screen one, then you replace the editor scrollback and then you close the editor, the pane will get the geometry of the buffer at exit point, which due to full screen was the max geometry. So, when you take the pane out of the full screen, then it will remain maximized. I will look into it. |
I'm closing this issue for now though because the feature itself was already implemented. @cosminadrianpopescu - please keep me updated on the issue. We can always open a new one. |
Implemented in 0.30.0 |
The experience should be:
Depends on: #1375
The text was updated successfully, but these errors were encountered: