Compare commits
No commits in common. "78cc4b2d24c8d75d2f4d9dc5c4b74e1b5b677a35" and "983c4844badd7820f5f5b6d2f3dbb1bed215e438" have entirely different histories.
78cc4b2d24
...
983c4844ba
2 changed files with 7 additions and 18 deletions
|
|
@ -196,10 +196,7 @@ pub fn restore_state_v1(self: *Self, data: []const u8) !void {
|
||||||
}
|
}
|
||||||
tp.trace(tp.channel.debug, .{ "restore_state_v1", "file", path, mtime, row, col });
|
tp.trace(tp.channel.debug, .{ "restore_state_v1", "file", path, mtime, row, col });
|
||||||
self.longest_file_path = @max(self.longest_file_path, path.len);
|
self.longest_file_path = @max(self.longest_file_path, path.len);
|
||||||
const stat = std.fs.cwd().statFile(path) catch {
|
const stat = std.fs.cwd().statFile(path) catch continue;
|
||||||
try self.update_mru_internal(path, mtime, row, col);
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
switch (stat.kind) {
|
switch (stat.kind) {
|
||||||
.sym_link, .file => try self.update_mru_internal(path, mtime, row, col),
|
.sym_link, .file => try self.update_mru_internal(path, mtime, row, col),
|
||||||
else => {},
|
else => {},
|
||||||
|
|
@ -263,10 +260,7 @@ pub fn restore_state_v0(self: *Self, data: []const u8) error{
|
||||||
}) {
|
}) {
|
||||||
tp.trace(tp.channel.debug, .{ "restore_state_v0", "file", path, mtime, row, col });
|
tp.trace(tp.channel.debug, .{ "restore_state_v0", "file", path, mtime, row, col });
|
||||||
self.longest_file_path = @max(self.longest_file_path, path.len);
|
self.longest_file_path = @max(self.longest_file_path, path.len);
|
||||||
const stat = std.fs.cwd().statFile(path) catch {
|
const stat = std.fs.cwd().statFile(path) catch continue;
|
||||||
try self.update_mru_internal(path, mtime, row, col);
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
switch (stat.kind) {
|
switch (stat.kind) {
|
||||||
.sym_link, .file => try self.update_mru_internal(path, mtime, row, col),
|
.sym_link, .file => try self.update_mru_internal(path, mtime, row, col),
|
||||||
else => {},
|
else => {},
|
||||||
|
|
@ -2070,16 +2064,14 @@ pub fn process_git(self: *Self, parent: tp.pid_ref, m: tp.message) (OutOfMemoryE
|
||||||
try self.loaded(parent);
|
try self.loaded(parent);
|
||||||
} else if (try m.match(.{ tp.any, tp.any, "workspace_files", tp.extract(&path) })) {
|
} else if (try m.match(.{ tp.any, tp.any, "workspace_files", tp.extract(&path) })) {
|
||||||
self.longest_file_path = @max(self.longest_file_path, path.len);
|
self.longest_file_path = @max(self.longest_file_path, path.len);
|
||||||
const mtime: i128 = blk: {
|
const stat = std.fs.cwd().statFile(path) catch return;
|
||||||
break :blk (std.fs.cwd().statFile(path) catch break :blk 0).mtime;
|
|
||||||
};
|
|
||||||
const file_type: []const u8, const file_icon: []const u8, const file_color: u24 = guess_file_type(path);
|
const file_type: []const u8, const file_icon: []const u8, const file_color: u24 = guess_file_type(path);
|
||||||
(try self.pending.addOne(self.allocator)).* = .{
|
(try self.pending.addOne(self.allocator)).* = .{
|
||||||
.path = try self.allocator.dupe(u8, path),
|
.path = try self.allocator.dupe(u8, path),
|
||||||
.type = file_type,
|
.type = file_type,
|
||||||
.icon = file_icon,
|
.icon = file_icon,
|
||||||
.color = file_color,
|
.color = file_color,
|
||||||
.mtime = mtime,
|
.mtime = stat.mtime,
|
||||||
};
|
};
|
||||||
} else if (try m.match(.{ tp.any, tp.any, "workspace_files", tp.null_ })) {
|
} else if (try m.match(.{ tp.any, tp.any, "workspace_files", tp.null_ })) {
|
||||||
self.state.workspace_files = .done;
|
self.state.workspace_files = .done;
|
||||||
|
|
|
||||||
|
|
@ -1423,12 +1423,9 @@ pub const StoreToFileError = error{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn store_to_existing_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void {
|
pub fn store_to_existing_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void {
|
||||||
var atomic = blk: {
|
const stat = try cwd().statFile(file_path);
|
||||||
var write_buffer: [4096]u8 = undefined;
|
var write_buffer: [4096]u8 = undefined;
|
||||||
const stat = cwd().statFile(file_path) catch
|
var atomic = try cwd().atomicFile(file_path, .{ .mode = stat.mode, .write_buffer = &write_buffer });
|
||||||
break :blk try cwd().atomicFile(file_path, .{ .write_buffer = &write_buffer });
|
|
||||||
break :blk try cwd().atomicFile(file_path, .{ .mode = stat.mode, .write_buffer = &write_buffer });
|
|
||||||
};
|
|
||||||
defer atomic.deinit();
|
defer atomic.deinit();
|
||||||
try self.store_to_file_const(&atomic.file_writer.interface);
|
try self.store_to_file_const(&atomic.file_writer.interface);
|
||||||
try atomic.finish();
|
try atomic.finish();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue