fix: Writer.Allocation.initOwnedSlice does not append
This commit is contained in:
parent
720bb9515f
commit
4125db2617
2 changed files with 9 additions and 5 deletions
|
@ -93,9 +93,11 @@ pub fn get(file_type_name: []const u8) !?@This() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_config_file_path(allocator: std.mem.Allocator, file_type: []const u8) ![]u8 {
|
pub fn get_config_file_path(allocator: std.mem.Allocator, file_type: []const u8) ![]u8 {
|
||||||
var stream: std.Io.Writer.Allocating = .initOwnedSlice(allocator, try get_config_dir_path(allocator));
|
const config_dir_path = try get_config_dir_path(allocator);
|
||||||
|
var stream: std.Io.Writer.Allocating = .initOwnedSlice(allocator, config_dir_path);
|
||||||
defer stream.deinit();
|
defer stream.deinit();
|
||||||
const writer = &stream.writer;
|
const writer = &stream.writer;
|
||||||
|
writer.end = config_dir_path.len;
|
||||||
_ = try writer.writeAll(file_type);
|
_ = try writer.writeAll(file_type);
|
||||||
_ = try writer.writeAll(".conf");
|
_ = try writer.writeAll(".conf");
|
||||||
return stream.toOwnedSlice();
|
return stream.toOwnedSlice();
|
||||||
|
|
|
@ -562,12 +562,14 @@ const BindingSet = struct {
|
||||||
|
|
||||||
for (self.press.items) |binding| {
|
for (self.press.items) |binding| {
|
||||||
const cmd = binding.commands[0].command;
|
const cmd = binding.commands[0].command;
|
||||||
var hint: std.Io.Writer.Allocating = if (hints_map.get(cmd)) |previous|
|
var end: usize = 0;
|
||||||
.initOwnedSlice(allocator, previous)
|
var hint: std.Io.Writer.Allocating = if (hints_map.get(cmd)) |previous| blk: {
|
||||||
else
|
end = previous.len;
|
||||||
.init(allocator);
|
break :blk .initOwnedSlice(allocator, previous);
|
||||||
|
} else .init(allocator);
|
||||||
defer hint.deinit();
|
defer hint.deinit();
|
||||||
const writer = &hint.writer;
|
const writer = &hint.writer;
|
||||||
|
writer.end = end;
|
||||||
if (hint.written().len > 0) try writer.writeAll(", ");
|
if (hint.written().len > 0) try writer.writeAll(", ");
|
||||||
const count = binding.key_events.len;
|
const count = binding.key_events.len;
|
||||||
for (binding.key_events, 0..) |key_, n| {
|
for (binding.key_events, 0..) |key_, n| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue