From d6f5be3bb4571092452f7c43382cffe1a5bf8cc0 Mon Sep 17 00:00:00 2001 From: relhamdi Date: Mon, 25 May 2026 11:13:20 +0200 Subject: [PATCH] Add guards against trailing empty spaces --- src/utils.py | 4 ++++ web/prompt_option_picker.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/utils.py b/src/utils.py index dbd3586..68c9434 100644 --- a/src/utils.py +++ b/src/utils.py @@ -32,6 +32,10 @@ def parse_options(raw: str) -> list[str]: current_block: list[list[str]] = [] current_list: list[str] = [] + # Remove trailing empty line from paste artifacts + if lines and lines[-1].strip() == "" and len(lines) > 1: + lines = lines[:-1] + for i, line in enumerate(lines, 1): stripped = line.strip() diff --git a/web/prompt_option_picker.js b/web/prompt_option_picker.js index 678649a..7a59a39 100644 --- a/web/prompt_option_picker.js +++ b/web/prompt_option_picker.js @@ -50,6 +50,11 @@ const parseOptions = (raw) => { let currentBlock = []; let currentList = []; + // Remove trailing empty line from paste artifacts + if (lines.length > 1 && lines[lines.length - 1].trim() === "") { + lines.pop(); + } + for (const line of lines) { const stripped = line.trim();