Alternate files with ctrl-6 (#11367)

This is my stab at #7709 

I realize the code is flawed. There's no test coverage, I'm using
`clone()` and there are probably better ways to hook into the events.
Also, I didn't know what context to use for the keybinding. But maybe
with some pointers from someone who actually know what they're doing, I
can get this shippable.

Release Notes:

- vim: Added ctrl-6 for
[alternate-file](https://vimhelp.org/editing.txt.html#CTRL-%5E) to
navigate back and forth between two buffers.



https://github.com/zed-industries/zed/assets/261929/2d10494e-5668-4988-b7b4-417c922d6c61

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Robert Falkén 2024-05-10 19:40:08 +02:00 committed by GitHub
parent 0d26beb91b
commit 80d3eafa30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 60 additions and 0 deletions

View file

@ -2499,6 +2499,9 @@ impl Workspace {
self.zoomed_position = None;
cx.emit(Event::ZoomChanged);
self.update_active_view_for_followers(cx);
pane.model.update(cx, |pane, _| {
pane.track_alternate_file_items();
});
cx.notify();
}
@ -2516,6 +2519,9 @@ impl Workspace {
}
pane::Event::Remove => self.remove_pane(pane, cx),
pane::Event::ActivateItem { local } => {
pane.model.update(cx, |pane, _| {
pane.track_alternate_file_items();
});
if *local {
self.unfollow(&pane, cx);
}