Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions cecli/tools/read_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,34 @@ def execute(cls, coder, show, **kwargs):

# Validate arguments for this operation
if not is_provided(start_text) or not is_provided(end_text):
error_outputs.append(
cls.format_error(
coder,
(
f"Show operation {show_index + 1}: Provide both 'start_text' and"
" 'end_text'."
),
file_path,
start_text,
end_text,
show_index,
# Auto-fallback: if the file is in editable context and markers are
# missing/junk, show the whole file instead of erroring.
abs_fnames = getattr(coder, "abs_fnames", set())
abs_ro = getattr(coder, "abs_read_only_fnames", set())
try:
abs_path_check = coder.abs_root_path(file_path) if file_path else None
except Exception:
abs_path_check = None
if abs_path_check and (
abs_path_check in abs_fnames or abs_path_check in abs_ro
):
start_text = "@000"
end_text = "000@"
else:
error_outputs.append(
cls.format_error(
coder,
(
f"Show operation {show_index + 1}: Provide both 'start_text' and"
" 'end_text'."
),
file_path,
start_text,
end_text,
show_index,
)
)
)
continue
continue

if start_text.count("\n") > 4 or end_text.count("\n") > 4:
error_outputs.append(
Expand Down
2 changes: 1 addition & 1 deletion cecli/tools/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def is_provided(value, *, treat_zero_as_missing=False):
"""
if value is None:
return False
if isinstance(value, str) and value == "":
if isinstance(value, str) and value.strip().lower() in ("", "n/a", "null", "none"):
return False
if treat_zero_as_missing and isinstance(value, (int, float)) and value == 0:
return False
Expand Down
Loading