fix: post location updates to project_manager creating or navigating buffers
This fixes newly created files not showing in the find_files palette. It also fixes MRU ordering not updating when switching tabs. closes #331
This commit is contained in:
parent
19f88a8349
commit
03f2821e5f
1 changed files with 18 additions and 0 deletions
|
|
@ -264,6 +264,7 @@ fn open_style_config(self: *Self, Style: type) command.Result {
|
||||||
"conf",
|
"conf",
|
||||||
}));
|
}));
|
||||||
if (self.get_active_buffer()) |buffer| buffer.mark_not_ephemeral();
|
if (self.get_active_buffer()) |buffer| buffer.mark_not_ephemeral();
|
||||||
|
self.location_update_from_editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
|
|
@ -461,6 +462,7 @@ const cmds = struct {
|
||||||
try command.executeName("scroll_view_center", .{});
|
try command.executeName("scroll_view_center", .{});
|
||||||
}
|
}
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
|
self.location_update_from_editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open_help(self: *Self, _: Ctx) Result {
|
pub fn open_help(self: *Self, _: Ctx) Result {
|
||||||
|
|
@ -468,6 +470,7 @@ const cmds = struct {
|
||||||
try self.create_editor();
|
try self.create_editor();
|
||||||
try command.executeName("open_scratch_buffer", command.fmt(.{ "help", @embedFile("help.md"), "markdown" }));
|
try command.executeName("open_scratch_buffer", command.fmt(.{ "help", @embedFile("help.md"), "markdown" }));
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
|
self.location_update_from_editor();
|
||||||
}
|
}
|
||||||
pub const open_help_meta: Meta = .{ .description = "Open help" };
|
pub const open_help_meta: Meta = .{ .description = "Open help" };
|
||||||
|
|
||||||
|
|
@ -476,6 +479,7 @@ const cmds = struct {
|
||||||
try self.create_editor();
|
try self.create_editor();
|
||||||
try command.executeName("open_scratch_buffer", command.fmt(.{ "font test", @import("fonts.zig").font_test_text, "text" }));
|
try command.executeName("open_scratch_buffer", command.fmt(.{ "font test", @import("fonts.zig").font_test_text, "text" }));
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
|
self.location_update_from_editor();
|
||||||
}
|
}
|
||||||
pub const open_font_test_text_meta: Meta = .{ .description = "Open font glyph test text" };
|
pub const open_font_test_text_meta: Meta = .{ .description = "Open font glyph test text" };
|
||||||
|
|
||||||
|
|
@ -484,6 +488,7 @@ const cmds = struct {
|
||||||
try self.create_editor();
|
try self.create_editor();
|
||||||
try command.executeName("open_scratch_buffer", command.fmt(.{ "version", root.version_info, "gitcommit" }));
|
try command.executeName("open_scratch_buffer", command.fmt(.{ "version", root.version_info, "gitcommit" }));
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
|
self.location_update_from_editor();
|
||||||
}
|
}
|
||||||
pub const open_version_info_meta: Meta = .{ .description = "Version" };
|
pub const open_version_info_meta: Meta = .{ .description = "Version" };
|
||||||
|
|
||||||
|
|
@ -543,6 +548,7 @@ const cmds = struct {
|
||||||
"conf",
|
"conf",
|
||||||
}));
|
}));
|
||||||
if (self.get_active_buffer()) |buffer| buffer.mark_not_ephemeral();
|
if (self.get_active_buffer()) |buffer| buffer.mark_not_ephemeral();
|
||||||
|
self.location_update_from_editor();
|
||||||
}
|
}
|
||||||
pub const open_file_type_config_meta: Meta = .{
|
pub const open_file_type_config_meta: Meta = .{
|
||||||
.arguments = &.{.string},
|
.arguments = &.{.string},
|
||||||
|
|
@ -556,6 +562,7 @@ const cmds = struct {
|
||||||
try self.create_editor();
|
try self.create_editor();
|
||||||
try command.executeName("open_scratch_buffer", .{ .args = args });
|
try command.executeName("open_scratch_buffer", .{ .args = args });
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
|
self.location_update_from_editor();
|
||||||
}
|
}
|
||||||
pub const create_scratch_buffer_meta: Meta = .{ .arguments = &.{ .string, .string, .string } };
|
pub const create_scratch_buffer_meta: Meta = .{ .arguments = &.{ .string, .string, .string } };
|
||||||
|
|
||||||
|
|
@ -645,6 +652,7 @@ const cmds = struct {
|
||||||
if (buffer.is_ephemeral())
|
if (buffer.is_ephemeral())
|
||||||
self.buffer_manager.close_buffer(buffer);
|
self.buffer_manager.close_buffer(buffer);
|
||||||
}
|
}
|
||||||
|
self.location_update_from_editor();
|
||||||
}
|
}
|
||||||
pub const save_file_as_meta: Meta = .{ .arguments = &.{.string} };
|
pub const save_file_as_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
|
|
@ -1278,6 +1286,16 @@ pub fn location_update(self: *Self, m: tp.message) tp.result {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
const primary = editor.get_primary();
|
||||||
|
const row: usize = primary.cursor.row;
|
||||||
|
const col: usize = primary.cursor.col;
|
||||||
|
project_manager.update_mru(file_path, row, col, ephemeral) catch {};
|
||||||
|
}
|
||||||
|
|
||||||
fn location_jump(from: tp.pid_ref, file_path: []const u8, cursor: location_history.Cursor, selection: ?location_history.Selection) void {
|
fn location_jump(from: tp.pid_ref, file_path: []const u8, cursor: location_history.Cursor, selection: ?location_history.Selection) void {
|
||||||
if (selection) |sel|
|
if (selection) |sel|
|
||||||
from.send(.{ "cmd", "navigate", .{
|
from.send(.{ "cmd", "navigate", .{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue