feat: remove single trailing new line in shell_execute_insert
This commit is contained in:
parent
1c5dc9064d
commit
9d6b760f03
1 changed files with 14 additions and 1 deletions
|
@ -628,7 +628,20 @@ const cmds = struct {
|
||||||
const cmd = ctx.args;
|
const cmd = ctx.args;
|
||||||
const handlers = struct {
|
const handlers = struct {
|
||||||
fn out(parent: tp.pid_ref, _: []const u8, output: []const u8) void {
|
fn out(parent: tp.pid_ref, _: []const u8, output: []const u8) void {
|
||||||
parent.send(.{ "cmd", "insert_chars", .{output} }) catch {};
|
var pos: usize = 0;
|
||||||
|
var nl_count: usize = 0;
|
||||||
|
while (std.mem.indexOfScalarPos(u8, output, pos, '\n')) |next| {
|
||||||
|
pos = next + 1;
|
||||||
|
nl_count += 1;
|
||||||
|
}
|
||||||
|
const output_ = if (nl_count == 1 and output[output.len - 1] == '\n')
|
||||||
|
if (output.len > 2 and output[output.len - 2] == '\r')
|
||||||
|
output[0 .. output.len - 2]
|
||||||
|
else
|
||||||
|
output[0 .. output.len - 1]
|
||||||
|
else
|
||||||
|
output;
|
||||||
|
parent.send(.{ "cmd", "insert_chars", .{output_} }) catch {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try shell.execute(self.allocator, cmd, .{ .out = handlers.out });
|
try shell.execute(self.allocator, cmd, .{ .out = handlers.out });
|
||||||
|
|
Loading…
Add table
Reference in a new issue