Compare commits
2 commits
7e8f06396e
...
6ce8a2f61d
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ce8a2f61d | |||
| 4f68898f96 |
2 changed files with 27 additions and 7 deletions
|
|
@ -1515,14 +1515,19 @@ pub fn handle_editor_event(self: *Self, editor: *ed.Editor, m: tp.message) tp.re
|
||||||
|
|
||||||
if (try m.match(.{ "E", "close" })) {
|
if (try m.match(.{ "E", "close" })) {
|
||||||
if (!self.closing_project) {
|
if (!self.closing_project) {
|
||||||
const view = self.get_view_for_editor(editor) orelse return;
|
const view = self.get_view_for_editor(editor) orelse {
|
||||||
|
if (self.get_next_mru_buffer(.non_hidden)) |file_path|
|
||||||
|
self.show_file_async(file_path);
|
||||||
|
return;
|
||||||
|
};
|
||||||
if (self.get_next_mru_buffer_for_view(view, .non_hidden)) |file_path|
|
if (self.get_next_mru_buffer_for_view(view, .non_hidden)) |file_path|
|
||||||
self.show_file_async(file_path)
|
self.show_file_async(file_path)
|
||||||
|
else if (self.views.widgets.items.len == 1)
|
||||||
|
self.show_home_async()
|
||||||
else {
|
else {
|
||||||
if (self.views.widgets.items.len == 1)
|
tp.self_pid().send(.{ "cmd", "close_split", .{} }) catch return;
|
||||||
self.show_home_async()
|
if (self.get_next_mru_buffer(.non_hidden)) |file_path|
|
||||||
else
|
self.show_file_async(file_path);
|
||||||
tp.self_pid().send(.{ "cmd", "close_split", .{} }) catch return;
|
|
||||||
}
|
}
|
||||||
} else self.show_home_async();
|
} else self.show_home_async();
|
||||||
return;
|
return;
|
||||||
|
|
@ -1833,7 +1838,7 @@ fn create_home(self: *Self) !void {
|
||||||
tui.resize();
|
tui.resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_home_split(self: *Self) !void {
|
pub fn create_home_split(self: *Self) !void {
|
||||||
tui.reset_drag_context();
|
tui.reset_drag_context();
|
||||||
try self.add_and_activate_view(try home.create(self.allocator, Widget.to(self)));
|
try self.add_and_activate_view(try home.create(self.allocator, Widget.to(self)));
|
||||||
_ = try self.widgets_widget.msg(.{"splits_updated"});
|
_ = try self.widgets_widget.msg(.{"splits_updated"});
|
||||||
|
|
|
||||||
|
|
@ -462,7 +462,7 @@ pub const TabBar = struct {
|
||||||
fn move_tab_next(self: *Self) void {
|
fn move_tab_next(self: *Self) void {
|
||||||
tp.trace(tp.channel.debug, .{"move_tab_next"});
|
tp.trace(tp.channel.debug, .{"move_tab_next"});
|
||||||
const this_idx = self.find_buffer_tab(self.active_focused_buffer_ref orelse return) orelse return;
|
const this_idx = self.find_buffer_tab(self.active_focused_buffer_ref orelse return) orelse return;
|
||||||
const other_buffer_ref = self.find_next_tab_buffer() orelse return;
|
const other_buffer_ref = self.find_next_tab_buffer() orelse return self.move_tab_to_new_split(this_idx);
|
||||||
const other_idx = self.find_buffer_tab(other_buffer_ref) orelse return;
|
const other_idx = self.find_buffer_tab(other_buffer_ref) orelse return;
|
||||||
self.move_tab_to(other_idx, this_idx);
|
self.move_tab_to(other_idx, this_idx);
|
||||||
}
|
}
|
||||||
|
|
@ -537,6 +537,21 @@ pub const TabBar = struct {
|
||||||
navigate_to_buffer(src_tab.buffer_ref);
|
navigate_to_buffer(src_tab.buffer_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn move_tab_to_new_split(self: *Self, src_idx: usize) void {
|
||||||
|
const mv = tui.mainview() orelse return;
|
||||||
|
const src_tab = &self.tabs[src_idx];
|
||||||
|
var tabs_in_view: usize = 0;
|
||||||
|
for (self.tabs) |*tab| if (tab.view) |view| {
|
||||||
|
if (view == src_tab.view)
|
||||||
|
tabs_in_view += 1;
|
||||||
|
};
|
||||||
|
if (tabs_in_view > 1) {
|
||||||
|
const view = mv.get_view_count();
|
||||||
|
mv.create_home_split() catch return;
|
||||||
|
self.move_tab_to_view(view, src_idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn place_next_tab(self: *Self, position: enum { before, after }, buffer_ref: usize) void {
|
fn place_next_tab(self: *Self, position: enum { before, after }, buffer_ref: usize) void {
|
||||||
tp.trace(tp.channel.debug, .{ "place_next_tab", position, buffer_ref });
|
tp.trace(tp.channel.debug, .{ "place_next_tab", position, buffer_ref });
|
||||||
const tab_idx = for (self.tabs, 0..) |*tab, idx| if (tab.buffer_ref == buffer_ref) break idx else continue else {
|
const tab_idx = for (self.tabs, 0..) |*tab, idx| if (tab.buffer_ref == buffer_ref) break idx else continue else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue