fix(file): handle empty text segment reads
This commit is contained in:
parent
f198c0c63e
commit
8de6275912
@ -122,6 +122,16 @@ def _read_text_segment(root, payload):
|
||||
}
|
||||
data, lines = _read_text(target)
|
||||
total = len(lines)
|
||||
if total == 0:
|
||||
return {
|
||||
"success": True,
|
||||
"path": rel,
|
||||
"content": "",
|
||||
"size": size,
|
||||
"line_start": 0,
|
||||
"line_end": 0,
|
||||
"total_lines": 0
|
||||
}
|
||||
line_start = start if start and start > 0 else 1
|
||||
line_end = end if end and end >= line_start else total
|
||||
if line_start > total:
|
||||
|
||||
@ -495,6 +495,17 @@ class FileManager:
|
||||
|
||||
lines = result["lines"]
|
||||
total_lines = len(lines)
|
||||
if total_lines == 0:
|
||||
relative_path = self._relative_path(full_path)
|
||||
return {
|
||||
"success": True,
|
||||
"path": relative_path,
|
||||
"content": "",
|
||||
"size": result["size"],
|
||||
"line_start": 0,
|
||||
"line_end": 0,
|
||||
"total_lines": 0,
|
||||
}
|
||||
start = start_line if start_line and start_line > 0 else 1
|
||||
end = end_line if end_line and end_line >= start else total_lines
|
||||
if start > total_lines:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user