From 9570dceaa8fd74b164b546aaf019f8388a9573a7 Mon Sep 17 00:00:00 2001 From: James Westman Date: Fri, 26 Jul 2024 22:08:22 -0500 Subject: [PATCH] errors: In suggestions, use "insert" or "remove" Previously it always said "replace", leading to incorrect wording. --- blueprintcompiler/errors.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/blueprintcompiler/errors.py b/blueprintcompiler/errors.py index 01058fd..a799e80 100644 --- a/blueprintcompiler/errors.py +++ b/blueprintcompiler/errors.py @@ -113,9 +113,17 @@ at {filename} line {line_num} column {col_num}: if action.edit_range is not None else self.range.text ) - stream.write( - f"suggestion: replace {Colors.RED}{old}{Colors.CLEAR} with {Colors.GREEN}{action.replace_with}{Colors.CLEAR}\n" - ) + + if old == "": + stream.write( + f"suggestion: insert {Colors.GREEN}{action.replace_with}{Colors.CLEAR}\n" + ) + elif action.replace_with == "": + stream.write(f"suggestion: remove {Colors.RED}{old}{Colors.CLEAR}\n") + else: + stream.write( + f"suggestion: replace {Colors.RED}{old}{Colors.CLEAR} with {Colors.GREEN}{action.replace_with}{Colors.CLEAR}\n" + ) for ref in self.references: line_num, col_num = utils.idx_to_pos(ref.range.start + 1, code)