Compare commits
No commits in common. "d3ae5e0e092184eec277ada2b161658301993b64" and "bad1ededc1789fde26ff3205a1fe19a52373e931" have entirely different histories.
d3ae5e0e09
...
bad1ededc1
6 changed files with 9 additions and 69 deletions
|
|
@ -49,7 +49,6 @@ meta: ?[]const u8 = null,
|
|||
lsp_version: usize = 1,
|
||||
vcs_id: ?[]const u8 = null,
|
||||
vcs_content: ?ArrayList(u8) = null,
|
||||
last_view: ?usize = null,
|
||||
|
||||
undo_head: ?*UndoNode = null,
|
||||
redo_head: ?*UndoNode = null,
|
||||
|
|
@ -1242,14 +1241,6 @@ pub inline fn get_file_path(self: *const Self) []const u8 {
|
|||
return self.file_path_buf.items;
|
||||
}
|
||||
|
||||
pub fn set_last_view(self: *Self, last_view: ?usize) void {
|
||||
self.last_view = last_view;
|
||||
}
|
||||
|
||||
pub fn get_last_view(self: *Self) ?usize {
|
||||
return self.last_view;
|
||||
}
|
||||
|
||||
pub fn set_vcs_id(self: *Self, vcs_id: []const u8) error{OutOfMemory}!bool {
|
||||
if (self.vcs_id) |old_id| {
|
||||
if (std.mem.eql(u8, old_id, vcs_id)) return false;
|
||||
|
|
@ -1696,7 +1687,6 @@ pub fn write_state(self: *const Self, writer: *std.Io.Writer) error{ Stop, OutOf
|
|||
self.hidden,
|
||||
self.ephemeral,
|
||||
self.auto_save,
|
||||
self.last_view,
|
||||
dirty,
|
||||
self.meta,
|
||||
self.file_type_name,
|
||||
|
|
@ -1722,7 +1712,6 @@ pub fn extract_state(self: *Self, iter: *[]const u8) !void {
|
|||
cbor.extract(&self.hidden),
|
||||
cbor.extract(&self.ephemeral),
|
||||
cbor.extract(&self.auto_save),
|
||||
cbor.extract(&self.last_view),
|
||||
cbor.extract(&dirty),
|
||||
cbor.extract(&meta),
|
||||
cbor.extract(&file_type_name),
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@ pub fn retire(_: *Self, buffer: *Buffer, meta: ?[]const u8) void {
|
|||
|
||||
pub fn close_buffer(self: *Self, buffer: *Buffer) void {
|
||||
buffer.hidden = true;
|
||||
buffer.set_last_view(null);
|
||||
tp.trace(tp.channel.debug, .{ "buffer", "close", buffer.get_file_path(), "hidden", buffer.hidden, "ephemeral", buffer.ephemeral });
|
||||
if (buffer.is_ephemeral())
|
||||
self.delete_buffer(buffer);
|
||||
|
|
|
|||
|
|
@ -6835,14 +6835,12 @@ pub const EditorWidget = struct {
|
|||
if (self.focused) return;
|
||||
self.commands.register() catch @panic("editor.commands.register");
|
||||
self.focused = true;
|
||||
command.executeName("enter_mode_default", .{}) catch {};
|
||||
self.editor.send_focus_events() catch {};
|
||||
}
|
||||
|
||||
pub fn unfocus(self: *Self) void {
|
||||
if (self.focused) self.commands.unregister();
|
||||
self.focused = false;
|
||||
command.executeName("enter_mode_default", .{}) catch {};
|
||||
}
|
||||
|
||||
pub fn update(self: *Self) void {
|
||||
|
|
|
|||
|
|
@ -151,16 +151,14 @@ pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
|
|||
}
|
||||
|
||||
pub fn focus(self: *Self) void {
|
||||
if (self.focused) return;
|
||||
self.unfocus();
|
||||
self.commands.register() catch @panic("home.commands.register");
|
||||
self.focused = true;
|
||||
command.executeName("enter_mode", command.Context.fmt(.{"home"})) catch {};
|
||||
}
|
||||
|
||||
pub fn unfocus(self: *Self) void {
|
||||
if (self.focused) self.commands.unregister();
|
||||
self.focused = false;
|
||||
command.executeName("enter_mode_default", .{}) catch {};
|
||||
}
|
||||
|
||||
fn add_menu_command(self: *Self, command_name: []const u8, description: []const u8, hint: []const u8, menu: anytype) !void {
|
||||
|
|
|
|||
|
|
@ -582,9 +582,7 @@ const cmds = struct {
|
|||
fn navigate_complete(self: *Self, view: ?usize, f: []const u8, goto_args: []const u8, line: ?i64, column: ?i64, offset: ?i64) Result {
|
||||
if (view) |n| try self.focus_view(n);
|
||||
|
||||
const different_file = if (self.get_active_file_path()) |active_file_path| !std.mem.eql(u8, active_file_path, f) else true;
|
||||
|
||||
if (view == null or different_file) {
|
||||
if (view == null) {
|
||||
if (self.get_active_editor()) |editor| {
|
||||
editor.send_editor_jump_source() catch {};
|
||||
}
|
||||
|
|
@ -1480,18 +1478,14 @@ pub fn handle_editor_event(self: *Self, editor: *ed.Editor, m: tp.message) tp.re
|
|||
var sel: ed.Selection = undefined;
|
||||
|
||||
if (try m.match(.{ "E", "location", tp.more }))
|
||||
return self.location_update(editor, m);
|
||||
return self.location_update(m);
|
||||
|
||||
if (try m.match(.{ "E", "close" })) {
|
||||
if (!self.closing_project) {
|
||||
if (self.get_next_mru_buffer_same_view_only(.non_hidden)) |file_path|
|
||||
if (self.get_next_mru_buffer(.non_hidden)) |file_path|
|
||||
self.show_file_async(file_path)
|
||||
else {
|
||||
if (self.views.widgets.items.len == 1)
|
||||
self.show_home_async()
|
||||
else
|
||||
tp.self_pid().send(.{ "cmd", "close_split", .{} }) catch return;
|
||||
}
|
||||
self.show_home_async();
|
||||
} else self.show_home_async();
|
||||
return;
|
||||
}
|
||||
|
|
@ -1517,11 +1511,11 @@ pub fn handle_editor_event(self: *Self, editor: *ed.Editor, m: tp.message) tp.re
|
|||
}
|
||||
}
|
||||
|
||||
pub fn location_update(self: *Self, editor: *ed.Editor, m: tp.message) tp.result {
|
||||
pub fn location_update(self: *Self, m: tp.message) tp.result {
|
||||
var row: usize = 0;
|
||||
var col: usize = 0;
|
||||
const file_path = editor.file_path orelse return;
|
||||
const ephemeral = if (editor.buffer) |buffer| buffer.is_ephemeral() else false;
|
||||
const file_path = self.get_active_file_path() orelse return;
|
||||
const ephemeral = if (self.get_active_buffer()) |buffer| buffer.is_ephemeral() else false;
|
||||
|
||||
if (try m.match(.{ tp.any, tp.any, tp.any, tp.extract(&row), tp.extract(&col) })) {
|
||||
if (row == 0 and col == 0) return;
|
||||
|
|
@ -1540,8 +1534,6 @@ pub fn location_update_from_editor(self: *Self) void {
|
|||
const editor = self.get_active_editor() orelse return;
|
||||
const file_path = editor.file_path orelse return;
|
||||
const ephemeral = if (editor.buffer) |buffer| buffer.is_ephemeral() else false;
|
||||
if (editor.buffer) |buffer|
|
||||
buffer.set_last_view(self.active_view);
|
||||
const primary = editor.get_primary();
|
||||
const row: usize = primary.cursor.row;
|
||||
const col: usize = primary.cursor.col;
|
||||
|
|
@ -1624,8 +1616,6 @@ pub fn get_view_for_file(self: *Self, file_path: []const u8) ?usize {
|
|||
if (std.mem.eql(u8, p.editor.file_path orelse continue, file_path))
|
||||
return n;
|
||||
}
|
||||
if (self.buffer_manager.get_buffer_for_file(file_path)) |buffer|
|
||||
return buffer.get_last_view();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -1927,41 +1917,10 @@ fn send_buffer_did_open(allocator: std.mem.Allocator, buffer: *Buffer) !void {
|
|||
project_manager.request_vcs_id(buffer.get_file_path()) catch {};
|
||||
}
|
||||
|
||||
fn get_next_mru_buffer_same_view_only(self: *Self, mode: enum { all, hidden, non_hidden }) ?[]const u8 {
|
||||
const buffers = self.buffer_manager.list_most_recently_used(self.allocator) catch return null;
|
||||
defer self.allocator.free(buffers);
|
||||
const active_file_path = self.get_active_file_path();
|
||||
for (buffers) |buffer| {
|
||||
if (active_file_path) |fp| if (std.mem.eql(u8, fp, buffer.get_file_path()))
|
||||
continue;
|
||||
if (switch (mode) {
|
||||
.all => false,
|
||||
.hidden => !buffer.hidden,
|
||||
.non_hidden => buffer.hidden,
|
||||
}) continue;
|
||||
if (buffer.get_last_view() != self.active_view)
|
||||
continue;
|
||||
return buffer.get_file_path();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
fn get_next_mru_buffer(self: *Self, mode: enum { all, hidden, non_hidden }) ?[]const u8 {
|
||||
const buffers = self.buffer_manager.list_most_recently_used(self.allocator) catch return null;
|
||||
defer self.allocator.free(buffers);
|
||||
const active_file_path = self.get_active_file_path();
|
||||
for (buffers) |buffer| {
|
||||
if (active_file_path) |fp| if (std.mem.eql(u8, fp, buffer.get_file_path()))
|
||||
continue;
|
||||
if (switch (mode) {
|
||||
.all => false,
|
||||
.hidden => !buffer.hidden,
|
||||
.non_hidden => buffer.hidden,
|
||||
}) continue;
|
||||
if (buffer.get_last_view() != self.active_view)
|
||||
continue;
|
||||
return buffer.get_file_path();
|
||||
}
|
||||
for (buffers) |buffer| {
|
||||
if (active_file_path) |fp| if (std.mem.eql(u8, fp, buffer.get_file_path()))
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -543,9 +543,6 @@ fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
|
|||
if (try m.match(.{ "PRJ", tp.more })) // drop late project manager query responses
|
||||
return;
|
||||
|
||||
if (try m.match(.{ "DIFF", tp.more })) // drop late diff responses
|
||||
return;
|
||||
|
||||
if (try m.match(.{"INPUT_IDLE"})) {
|
||||
if (self.input_idle_timer) |*t| t.deinit();
|
||||
self.input_idle_timer = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue