From 05fe3e7ec3d20c26f3f1cb500ab9ee0e9a0f01f5 Mon Sep 17 00:00:00 2001 From: Bryan Lee <38807139+liby@users.noreply.github.com> Date: Sun, 12 Jan 2025 19:54:51 +0800 Subject: [PATCH] Ensure last action's documentation is properly generated The issue was caused by the documentation generation logic not writing the final buffered content. --- src/build/webgen/main_actions.zig | 7 +++++++ src/input/Binding.zig | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/build/webgen/main_actions.zig b/src/build/webgen/main_actions.zig index f4dffbc13..e802aac4a 100644 --- a/src/build/webgen/main_actions.zig +++ b/src/build/webgen/main_actions.zig @@ -50,9 +50,16 @@ pub fn genKeybindActions(writer: anytype) !void { '\n', ); while (iter.next()) |s| { + // If it is the last line and empty, then skip it. + if (iter.peek() == null and s.len == 0) continue; try buffer.appendSlice(s); try buffer.appendSlice("\n"); } } } + + // Write any remaining buffered documentation + if (buffer.items.len > 0) { + try writer.writeAll(buffer.items); + } } diff --git a/src/input/Binding.zig b/src/input/Binding.zig index 48725fb13..f29030bde 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -236,9 +236,9 @@ pub const Action = union(enum) { /// Send an `ESC` sequence. esc: []const u8, - // Send the given text. Uses Zig string literal syntax. This is currently - // not validated. If the text is invalid (i.e. contains an invalid escape - // sequence), the error will currently only show up in logs. + /// Send the given text. Uses Zig string literal syntax. This is currently + /// not validated. If the text is invalid (i.e. contains an invalid escape + /// sequence), the error will currently only show up in logs. text: []const u8, /// Send data to the pty depending on whether cursor key mode is enabled