feat: action map refactor, bugfix
This commit is contained in:
@@ -65,6 +65,22 @@ pub fn getFullNameByNativePath(allocator: std.mem.Allocator, nativePath: NativeP
|
||||
}
|
||||
|
||||
pub fn getNativePathByFullName(allocator: std.mem.Allocator, fullName: FullName) ![]u8 {
|
||||
std.debug.assert(!std.mem.endsWith(u8, fullName.path, "/"));
|
||||
|
||||
if (fullName.path.len < LocalProviderId.len or
|
||||
!std.mem.eql(u8, fullName.path[0..LocalProviderId.len], LocalProviderId))
|
||||
{
|
||||
return ProviderError.WrongProvider;
|
||||
}
|
||||
|
||||
//NOTE: their might be an other edge case where the fullname is local/ that is not handled by this
|
||||
if (fullName.path.len == LocalProviderId.len) {
|
||||
if (native_os == .linux)
|
||||
return try std.fmt.allocPrint(allocator, "/", .{})
|
||||
else
|
||||
return ProviderError.WrongProvider;
|
||||
}
|
||||
|
||||
const fullNameWithoutId = fullName.path[LocalProviderId.len + 1 ..];
|
||||
var native_path = try std.mem.replaceOwned(u8, allocator, fullNameWithoutId, "/", std.fs.path.sep_str);
|
||||
|
||||
@@ -217,6 +233,7 @@ const models = @import("../models.zig");
|
||||
const Provider = @import("provider.zig").Provider;
|
||||
const ProviderVTable = @import("provider.zig").VTable;
|
||||
const GetItemsError = @import("provider.zig").GetItemsError;
|
||||
const ProviderError = @import("provider.zig").ProviderError;
|
||||
const InitContext = @import("provider.zig").InitContext;
|
||||
|
||||
const FullName = models.FullName;
|
||||
|
||||
@@ -18,6 +18,10 @@ pub const GetItemsError = error{
|
||||
OutOfMemory,
|
||||
NotExists,
|
||||
NotSupported,
|
||||
} || ProviderError;
|
||||
|
||||
pub const ProviderError = error{
|
||||
WrongProvider,
|
||||
};
|
||||
|
||||
pub const Provider = struct {
|
||||
|
||||
@@ -39,6 +39,7 @@ pub const Tab = struct {
|
||||
pub fn setCurrentLocation(self: *Tab, newLocationFullName: models.FullName) !void {
|
||||
if (self.currentLocation) |c| {
|
||||
c.item.deinit();
|
||||
self.currentLocation = null;
|
||||
}
|
||||
|
||||
self.cleanCurrentItem();
|
||||
@@ -201,7 +202,7 @@ pub const Tab = struct {
|
||||
};
|
||||
|
||||
const resolvedParent = location.item.provider.getItemByFullName(parentFullName, &.{}, allocator) catch |e| {
|
||||
std.debug.print("error {} {s}\r\n", .{ e, parentFullName.path });
|
||||
std.debug.print("error {s}:{} {} {s}\r\n", .{ @src().file, @src().line, e, parentFullName.path });
|
||||
return;
|
||||
};
|
||||
const parentContainer = switch (resolvedParent.item) {
|
||||
@@ -229,7 +230,7 @@ pub const Tab = struct {
|
||||
const allocator = arena.allocator();
|
||||
|
||||
const resolvedChild = newSelectedItemArc.value.*.provider.getItemByFullName(newSelectedItemArc.value.*.fullName, &.{}, allocator) catch |e| {
|
||||
std.debug.print("error {} {s}\r\n", .{ e, newSelectedItemArc.value.*.fullName.path });
|
||||
std.debug.print("error {s}:{} {} {s}\r\n", .{ @src().file, @src().line, e, newSelectedItemArc.value.*.fullName.path });
|
||||
return;
|
||||
};
|
||||
const childContainer = switch (resolvedChild.item) {
|
||||
@@ -362,7 +363,7 @@ fn loadItems(
|
||||
for (location.children.data.items[processed_number..]) |item_fullname| {
|
||||
const resolvedItem = location.item.provider.getItemByFullName(item_fullname, &.{}, allocator) catch |e| {
|
||||
//TODO: save error to container errors
|
||||
std.debug.print("error {} {s}\r\n", .{ e, item_fullname.path });
|
||||
std.debug.print("error {s}:{} {} {s}\r\n", .{ @src().file, @src().line, e, item_fullname.path });
|
||||
continue;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user