delete_lines
Remove specific lines from files after verifying them with read_file to ensure accurate file modifications.
Instructions
Deletes the given lines in the file.
Requires that the same range of lines was previously read using the read_file tool to verify correctness
of the operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relative_path | Yes | The relative path to the file. | |
| start_line | Yes | The 0-based index of the first line to be deleted. | |
| end_line | Yes | The 0-based index of the last line to be deleted. |
Implementation Reference
- src/serena/symbol.py:872-886 (handler)The main handler function for the 'delete_lines' tool in the SymbolManager class. It deletes the specified range of lines (0-based indexing, inclusive) from the given relative file path by wrapping the language server's delete operation in a file editing context manager.def delete_lines(self, relative_path: str, start_line: int, end_line: int) -> None: """ Deletes lines in the given file. :param start_line: the 0-based index of the first line to delete (inclusive) :param end_line: the 0-based index of the last line to delete (inclusive) """ start_col = 0 end_line_for_delete = end_line + 1 end_col = 0 with self._edited_file(relative_path): start_pos = Position(line=start_line, character=start_col) end_pos = Position(line=end_line_for_delete, character=end_col) self._lang_server.delete_text_between_positions(relative_path, start_pos, end_pos)