Skip to content

Commit 4eaa794

Browse files
committed
Better wording when reporting ambiguity
1 parent f4edadf commit 4eaa794

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/cedarscript_editor/cedarscript_editor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ def __init__(self, command_ordinal: int, description: str):
5050
f"due to changes that left the file in an invalid state (check that by re-reading the file!)</note>"
5151
)
5252
super().__init__(
53-
f"<error-details><error-location>COMMAND #{command_ordinal}</error-location>{note}"
54-
f"<description>{description}</description>"
53+
f"<error-details>\n<error-location>COMMAND #{command_ordinal}</error-location>"
54+
f"\n<description>{description}</description>"
55+
f"{note}"
5556
"<suggestion>NEVER apologize; just relax, take a deep breath, think step-by-step and write "
5657
"an in-depth analysis of what went wrong (specifying which command ordinal failed), "
5758
"then acknowledge which commands were already applied and concisely describe "

src/cedarscript_editor/tree_sitter_identifier_finder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def _find_identifier(language, source: Sequence[str], tree, query_scm: dict[str,
145145
return None
146146
if candidate_count > 1 and marker.offset is None:
147147
raise ValueError(
148-
f"There are {candidate_count} {marker.type} identifiers named `{marker.value}`. "
148+
f"The {marker.type} identifier named `{marker.value}` is ambiguous (found {candidate_count} matches). "
149149
f"Choose an `OFFSET` between 0 and {candidate_count - 1} to determine how many to skip. "
150150
f"Example to reference the *last* `{marker.value}`: `OFFSET {candidate_count - 1}`"
151151
)

src/text_manipulation/range_spec.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ def from_line_marker(
192192
match_type_count = len(matches[match_type])
193193
if search_term.offset is None and match_type_count > 1:
194194
raise ValueError(
195-
f"There are {match_type_count} lines matching `{search_term.value}`. "
196-
"Suggestions: 1) Try using a *different line* as marker (a couple lines before or after the one "
197-
"you tried); 2) If you wanted to *REPLACE* line, "
198-
"try instead to replace a *SEGMENT* of a couple of lines."
195+
f"Line marker `{search_term.value}` is ambiguous (found {match_type_count} lines matching it) "
196+
"Suggestions: 1) To disambiguate, try using a *different line* as marker (a couple lines before or "
197+
"after the one you tried); 2) If you wanted to *REPLACE* line, try instead to replace a *SEGMENT* "
198+
"a couple of lines long."
199199
# f"Add an `OFFSET` (after the line marker) and a number between 0 and {match_type_count - 1}
200200
# to determine how many to skip. "
201201
# f"Example to reference the *last* one of those:

0 commit comments

Comments
 (0)