Compare commits
No commits in common. "4cb0f7df02a5e2428518ffdc3dc0a10ec7491197" and "672d92424d97265ebf5f44ff21f50abb16076c7f" have entirely different histories.
4cb0f7df02
...
672d92424d
3 changed files with 14 additions and 46 deletions
|
|
@ -325,7 +325,6 @@ pub const Editor = struct {
|
|||
chunks: usize = 0,
|
||||
eol_mode: Buffer.EolMode = .lf,
|
||||
utf8_sanitized: bool = false,
|
||||
no_changes: bool = false,
|
||||
} = null,
|
||||
matches: Match.List = .empty,
|
||||
match_token: usize = 0,
|
||||
|
|
@ -722,7 +721,7 @@ pub const Editor = struct {
|
|||
buffer.file_type_icon = fti;
|
||||
buffer.file_type_color = ftc;
|
||||
}
|
||||
const auto_save = if (self.buffer) |b| b.is_auto_save() and !b.is_ephemeral() else false;
|
||||
const auto_save = if (self.buffer) |b| b.is_auto_save() else false;
|
||||
|
||||
if (buffer_meta) |meta| {
|
||||
const frame_ = tracy.initZone(@src(), .{ .name = "extract_state" });
|
||||
|
|
@ -804,7 +803,7 @@ pub const Editor = struct {
|
|||
if (self.file_path) |file_path| {
|
||||
if (self.buffer) |b_mut| try b_mut.store_to_file_and_clean(file_path);
|
||||
} else return error.SaveNoFileName;
|
||||
try self.send_editor_save(self.file_path.?, b.is_auto_save() and !b.is_ephemeral());
|
||||
try self.send_editor_save(self.file_path.?, b.is_auto_save());
|
||||
self.last.dirty = false;
|
||||
self.update_event() catch {};
|
||||
}
|
||||
|
|
@ -1850,7 +1849,7 @@ pub const Editor = struct {
|
|||
_ = try self.handlers.msg(.{ "E", "update", token_from(new_root), token_from(old_root), @intFromEnum(eol_mode) });
|
||||
if (self.buffer) |buffer| if (self.syntax) |_| if (self.file_path) |file_path| if (old_root != null and new_root != null)
|
||||
project_manager.did_change(file_path, buffer.lsp_version, try text_from_root(new_root, eol_mode), try text_from_root(old_root, eol_mode), eol_mode) catch {};
|
||||
if (self.buffer) |b| if (b.is_auto_save() and !b.is_ephemeral())
|
||||
if (self.buffer) |b| if (b.is_auto_save())
|
||||
tp.self_pid().send(.{ "cmd", "save_file", .{} }) catch {};
|
||||
}
|
||||
|
||||
|
|
@ -6278,45 +6277,24 @@ pub const Editor = struct {
|
|||
if (state.before_root != root) return error.Stop;
|
||||
defer self.filter_deinit();
|
||||
const primary = self.get_primary();
|
||||
self.cancel_all_selections();
|
||||
self.cancel_all_matches();
|
||||
if (state.whole_file) |buf| {
|
||||
if (buf.items.len == 0) {
|
||||
self.logger.print_err("filter", "empty filter result", .{});
|
||||
return;
|
||||
}
|
||||
const old_hash = blk: {
|
||||
var content: std.Io.Writer.Allocating = .init(self.allocator);
|
||||
defer content.deinit();
|
||||
try root.store(&content.writer, try self.buf_eol_mode());
|
||||
break :blk std.hash.XxHash3.hash(0, content.written());
|
||||
};
|
||||
const new_hash = std.hash.XxHash3.hash(0, buf.items);
|
||||
if (old_hash == new_hash) {
|
||||
state.no_changes = true;
|
||||
} else {
|
||||
self.cancel_all_selections();
|
||||
self.cancel_all_matches();
|
||||
state.work_root = try b.load_from_string(buf.items, &state.eol_mode, &state.utf8_sanitized);
|
||||
state.bytes = buf.items.len;
|
||||
state.chunks = 1;
|
||||
primary.cursor = state.old_primary.cursor;
|
||||
}
|
||||
state.work_root = try b.load_from_string(buf.items, &state.eol_mode, &state.utf8_sanitized);
|
||||
state.bytes = buf.items.len;
|
||||
state.chunks = 1;
|
||||
primary.cursor = state.old_primary.cursor;
|
||||
} else {
|
||||
self.cancel_all_selections();
|
||||
self.cancel_all_matches();
|
||||
const sel = primary.enable_selection(root, self.metrics);
|
||||
sel.begin = state.begin;
|
||||
sel.end = state.pos.cursor;
|
||||
if (state.old_primary_reversed) sel.reverse();
|
||||
primary.cursor = sel.end;
|
||||
}
|
||||
try self.update_buf_and_eol_mode(state.work_root, state.eol_mode, state.utf8_sanitized);
|
||||
primary.cursor.clamp_to_buffer(state.work_root, self.metrics);
|
||||
self.logger.print("filter: done (bytes:{d} chunks:{d})", .{ state.bytes, state.chunks });
|
||||
if (state.no_changes) {
|
||||
self.logger.print("filter: no changes", .{});
|
||||
} else {
|
||||
try self.update_buf_and_eol_mode(state.work_root, state.eol_mode, state.utf8_sanitized);
|
||||
primary.cursor.clamp_to_buffer(state.work_root, self.metrics);
|
||||
self.reset_syntax();
|
||||
}
|
||||
self.reset_syntax();
|
||||
self.clamp();
|
||||
self.need_render();
|
||||
if (self.need_save_after_filter) |info| {
|
||||
|
|
@ -6511,7 +6489,7 @@ pub const Editor = struct {
|
|||
buffer.file_type_color = ftc;
|
||||
}
|
||||
const file_exists = if (self.buffer) |b| b.file_exists else false;
|
||||
const auto_save = if (self.buffer) |b| b.is_auto_save() and !b.is_ephemeral() else false;
|
||||
const auto_save = if (self.buffer) |b| b.is_auto_save() else false;
|
||||
try self.send_editor_open(self.file_path orelse "", file_exists, ftn, fti, ftc, auto_save);
|
||||
self.logger.print("file type {s}", .{file_type});
|
||||
}
|
||||
|
|
@ -6522,7 +6500,7 @@ pub const Editor = struct {
|
|||
const fti = if (self.file_type) |ft| ft.icon orelse file_type_config.default.icon else file_type_config.default.icon;
|
||||
const ftc = if (self.file_type) |ft| ft.color orelse file_type_config.default.color else file_type_config.default.color;
|
||||
const file_exists = if (self.buffer) |b| b.file_exists else false;
|
||||
const auto_save = if (self.buffer) |b| b.is_auto_save() and !b.is_ephemeral() else false;
|
||||
const auto_save = if (self.buffer) |b| b.is_auto_save() else false;
|
||||
try self.send_editor_open(self.file_path orelse "", file_exists, ftn, fti, ftc, auto_save);
|
||||
self.last = .{};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,10 +205,6 @@ fn get_replace_selection(replace: Buffer.Selection) ?Buffer.Selection {
|
|||
replace;
|
||||
}
|
||||
|
||||
pub fn complete(palette: *Type, _: ?*Type.ButtonType) !void {
|
||||
palette.menu.activate_selected();
|
||||
}
|
||||
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Pos) void {
|
||||
const values = get_values(button.opts.label);
|
||||
const editor = tui.get_active_editor() orelse return;
|
||||
|
|
|
|||
|
|
@ -554,12 +554,6 @@ pub fn Create(options: type) type {
|
|||
.icon = "",
|
||||
};
|
||||
|
||||
pub fn palette_menu_complete(self: *Self, _: Ctx) Result {
|
||||
if (@hasDecl(options, "complete"))
|
||||
options.complete(self, self.menu.get_selected()) catch {};
|
||||
}
|
||||
pub const palette_menu_complete_meta: Meta = .{};
|
||||
|
||||
pub fn palette_menu_activate(self: *Self, _: Ctx) Result {
|
||||
self.menu.activate_selected();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue