Compare commits
3 commits
195ba1e385
...
c0107e32e0
| Author | SHA1 | Date | |
|---|---|---|---|
| c0107e32e0 | |||
| 3a718bf6f6 | |||
| 0e0137677f |
5 changed files with 57 additions and 18 deletions
|
|
@ -600,12 +600,13 @@ pub fn walk_tree_entry(self: *Self, m: tp.message) OutOfMemoryError!void {
|
||||||
tp.extract(&file_color),
|
tp.extract(&file_color),
|
||||||
}) catch return)) return;
|
}) catch return)) return;
|
||||||
const mtime = (@as(i128, @intCast(mtime_high)) << 64) | @as(i128, @intCast(mtime_low));
|
const mtime = (@as(i128, @intCast(mtime_high)) << 64) | @as(i128, @intCast(mtime_low));
|
||||||
|
const ft = file_type_config.get(file_type) catch null;
|
||||||
|
|
||||||
self.longest_file_path = @max(self.longest_file_path, file_path.len);
|
self.longest_file_path = @max(self.longest_file_path, file_path.len);
|
||||||
(try self.pending.addOne(self.allocator)).* = .{
|
(try self.pending.addOne(self.allocator)).* = .{
|
||||||
.path = try self.allocator.dupe(u8, file_path),
|
.path = try self.allocator.dupe(u8, file_path),
|
||||||
.type = file_type,
|
.type = if (ft) |ft_| ft_.name else try self.allocator.dupe(u8, file_type),
|
||||||
.icon = file_icon,
|
.icon = if (ft) |ft_| ft_.icon orelse &.{} else try self.allocator.dupe(u8, file_icon),
|
||||||
.color = @intCast(file_color),
|
.color = @intCast(file_color),
|
||||||
.mtime = mtime,
|
.mtime = mtime,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ pub const BlameLine = struct {
|
||||||
author_stamp: usize,
|
author_stamp: usize,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub var retain_symlinks: bool = true;
|
||||||
|
|
||||||
arena: std.heap.ArenaAllocator,
|
arena: std.heap.ArenaAllocator,
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
external_allocator: Allocator,
|
external_allocator: Allocator,
|
||||||
|
|
@ -1599,7 +1601,14 @@ pub const StoreToFileError = error{
|
||||||
WriteFailed,
|
WriteFailed,
|
||||||
};
|
};
|
||||||
|
|
||||||
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 file_path = file_path_;
|
||||||
|
var link_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
|
if (retain_symlinks) blk: {
|
||||||
|
const link = cwd().readLink(file_path, &link_buf) catch break :blk;
|
||||||
|
file_path = link;
|
||||||
|
}
|
||||||
|
|
||||||
var atomic = blk: {
|
var atomic = blk: {
|
||||||
var write_buffer: [4096]u8 = undefined;
|
var write_buffer: [4096]u8 = undefined;
|
||||||
const stat = cwd().statFile(file_path) catch
|
const stat = cwd().statFile(file_path) catch
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,8 @@ keybind_mode: KeybindMode = .normal,
|
||||||
dropdown_keybinds: DropdownKeybindMode = .standard,
|
dropdown_keybinds: DropdownKeybindMode = .standard,
|
||||||
dropdown_limit: usize = 12,
|
dropdown_limit: usize = 12,
|
||||||
|
|
||||||
|
retain_symlinks: bool = true,
|
||||||
|
|
||||||
include_files: []const u8 = "",
|
include_files: []const u8 = "",
|
||||||
|
|
||||||
const default_actions = [_]IdleAction{.highlight_references};
|
const default_actions = [_]IdleAction{.highlight_references};
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ const root = @import("soft_root").root;
|
||||||
const tracy = @import("tracy");
|
const tracy = @import("tracy");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const file_link = @import("file_link");
|
const file_link = @import("file_link");
|
||||||
|
const Buffer = @import("Buffer");
|
||||||
|
|
||||||
pub const renderer = @import("renderer");
|
pub const renderer = @import("renderer");
|
||||||
const input = @import("input");
|
const input = @import("input");
|
||||||
|
|
@ -154,6 +155,8 @@ fn init(allocator: Allocator) InitError!*Self {
|
||||||
|
|
||||||
var conf, const conf_bufs = root.read_config(@import("config"), allocator);
|
var conf, const conf_bufs = root.read_config(@import("config"), allocator);
|
||||||
|
|
||||||
|
Buffer.retain_symlinks = conf.retain_symlinks;
|
||||||
|
|
||||||
if (@hasDecl(renderer, "install_crash_handler") and conf.start_debugger_on_crash)
|
if (@hasDecl(renderer, "install_crash_handler") and conf.start_debugger_on_crash)
|
||||||
renderer.jit_debugger_enabled = true;
|
renderer.jit_debugger_enabled = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,23 +169,14 @@ const FilteredWalker = struct {
|
||||||
try self.name_buffer.appendSlice(self.allocator, base.name);
|
try self.name_buffer.appendSlice(self.allocator, base.name);
|
||||||
switch (base.kind) {
|
switch (base.kind) {
|
||||||
.directory => {
|
.directory => {
|
||||||
if (is_filtered_dir(base.name))
|
_ = try self.next_directory(&base, &top, &containing);
|
||||||
continue;
|
continue;
|
||||||
var new_dir = top.iter.dir.openDir(base.name, .{ .iterate = true }) catch |err| switch (err) {
|
|
||||||
error.NameTooLong => @panic("unexpected error.NameTooLong"), // no path sep in base.name
|
|
||||||
else => continue,
|
|
||||||
};
|
|
||||||
{
|
|
||||||
errdefer new_dir.close();
|
|
||||||
try self.stack.append(self.allocator, .{
|
|
||||||
.iter = new_dir.iterateAssumeFirstIteration(),
|
|
||||||
.dirname_len = self.name_buffer.items.len,
|
|
||||||
});
|
|
||||||
top = &self.stack.items[self.stack.items.len - 1];
|
|
||||||
containing = &self.stack.items[self.stack.items.len - 2];
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
.file => return self.name_buffer.items,
|
.file => return self.name_buffer.items,
|
||||||
|
.sym_link => if (try self.next_sym_link(&base, &top, &containing, 5)) |file|
|
||||||
|
return file
|
||||||
|
else
|
||||||
|
continue,
|
||||||
else => continue,
|
else => continue,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -198,4 +189,37 @@ const FilteredWalker = struct {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn next_directory(self: *FilteredWalker, base: *const std.fs.Dir.Entry, top: **StackItem, containing: **StackItem) !void {
|
||||||
|
if (is_filtered_dir(base.name))
|
||||||
|
return;
|
||||||
|
var new_dir = top.*.iter.dir.openDir(base.name, .{ .iterate = true }) catch |err| switch (err) {
|
||||||
|
error.NameTooLong => @panic("unexpected error.NameTooLong"), // no path sep in base.name
|
||||||
|
else => return,
|
||||||
|
};
|
||||||
|
{
|
||||||
|
errdefer new_dir.close();
|
||||||
|
try self.stack.append(self.allocator, .{
|
||||||
|
.iter = new_dir.iterateAssumeFirstIteration(),
|
||||||
|
.dirname_len = self.name_buffer.items.len,
|
||||||
|
});
|
||||||
|
top.* = &self.stack.items[self.stack.items.len - 1];
|
||||||
|
containing.* = &self.stack.items[self.stack.items.len - 2];
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn next_sym_link(self: *FilteredWalker, base: *const std.fs.Dir.Entry, top: **StackItem, containing: **StackItem, stat_depth: usize) !?[]const u8 {
|
||||||
|
if (stat_depth == 0) return null;
|
||||||
|
const st = top.*.iter.dir.statFile(base.name) catch return null;
|
||||||
|
switch (st.kind) {
|
||||||
|
.directory => {
|
||||||
|
_ = try self.next_directory(base, top, containing);
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
.file => return self.name_buffer.items,
|
||||||
|
.sym_link => return try self.next_sym_link(base, top, containing, stat_depth - 1),
|
||||||
|
else => return null,
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue