parent
1be41aff8b
commit
0a8a8188cd
1 changed files with 14 additions and 3 deletions
|
|
@ -348,16 +348,27 @@ fn make_URI(self: *Self, file_path: ?[]const u8) LspError![]const u8 {
|
|||
var buf: std.Io.Writer.Allocating = .init(self.allocator);
|
||||
defer buf.deinit();
|
||||
const writer = &buf.writer;
|
||||
try writer.writeAll("file://");
|
||||
if (file_path) |path| {
|
||||
if (std.fs.path.isAbsolute(path)) {
|
||||
try writer.print("file://{s}", .{path});
|
||||
try write_URI_path(writer, path);
|
||||
} else {
|
||||
try writer.print("file://{s}{c}{s}", .{ self.name, std.fs.path.sep, path });
|
||||
try write_URI_path(writer, self.name);
|
||||
try writer.writeByte('/');
|
||||
try write_URI_path(writer, path);
|
||||
}
|
||||
} else try writer.print("file://{s}", .{self.name});
|
||||
} else try write_URI_path(writer, self.name);
|
||||
return buf.toOwnedSlice();
|
||||
}
|
||||
|
||||
fn write_URI_path(writer: *std.Io.Writer, path: []const u8) std.Io.Writer.Error!void {
|
||||
for (path) |c| try switch (c) {
|
||||
std.fs.path.sep => writer.writeByte('/'),
|
||||
':' => writer.writeAll("%3A"),
|
||||
else => writer.writeByte(c),
|
||||
};
|
||||
}
|
||||
|
||||
fn sort_files_by_mtime(self: *Self) void {
|
||||
sort_by_mtime(File, self.files.items);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue