This commit is contained in:
86cloudyun-afk 2026-04-24 18:25:07 -05:00 committed by GitHub
commit 438d436ae5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

@ -602,7 +602,7 @@ class CopilotACPClient:
content = path.read_text() if path.exists() else ""
line = params.get("line")
limit = params.get("limit")
if isinstance(line, int) and line > 1:
if isinstance(line, int) and line >= 1:
lines = content.splitlines(keepends=True)
start = line - 1
end = start + limit if isinstance(limit, int) and limit > 0 else None

View file

@ -94,6 +94,25 @@ class CopilotACPClientSafetyTests(unittest.TestCase):
self.assertNotIn("abc123def456", content)
self.assertIn("OPENAI_API_KEY=", content)
def test_read_text_file_honors_first_page_pagination(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
root = Path(tmpdir)
text_file = root / "sample.txt"
text_file.write_text("one\ntwo\nthree\n")
response = self._dispatch(
{
"jsonrpc": "2.0",
"id": 33,
"method": "fs/read_text_file",
"params": {"path": str(text_file), "line": 1, "limit": 1},
},
cwd=str(root),
)
content = ((response.get("result") or {}).get("content") or "")
self.assertEqual(content, "one\n")
def test_write_text_file_reuses_write_denylist(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
home = Path(tmpdir) / "home"