Added functionality for moving code block and deleting code block. - #13
Added functionality for moving code block and deleting code block.#13RajWorking wants to merge 7 commits into
Conversation
ryanhoangt
left a comment
There was a problem hiding this comment.
Regarding the lint issue, can you run make install-pre-commit-hooks to config pre-commit hook, and then try a dummy commit? I'll try to improve this and put in the README in future PRs
| # commonly ignored for libraries. | ||
| # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
| #poetry.lock | ||
| poetry.lock |
There was a problem hiding this comment.
I think we should add lock file into version control, similar to OH codebase, for consistency and reproducibility.
| raise EditorToolParameterMissingError(command, 'new_str') | ||
| return self.insert(_path, insert_line, new_str, enable_linting) | ||
| elif command == 'delete': | ||
| if not lines_range: |
There was a problem hiding this comment.
I'm thinking should we raise error here or delete the whole file content
| return self.delete(_path, lines_range) | ||
| elif command == 'move_code_block': | ||
| if not lines_range: | ||
| raise EditorToolParameterMissingError(command, 'lines_range') |
| """ | ||
| Deletes text content in file from the given range. | ||
| """ | ||
| try: |
There was a problem hiding this comment.
Can you help remove all the try-catch surrounding self.read_file? I think it's maybe not required as we already catch them in the method itself.
| output=f'Code block moved from {from_file} to {dst_file}.\n{delete_result.output}\n{insert_result.output}' | ||
| ) | ||
|
|
||
| def validate_path(self, command: Command, path: Path) -> None: |
There was a problem hiding this comment.
Do we need to do validation for the command to make sure path is not a directory? (And maybe a test case for it)
There was a problem hiding this comment.
Yes, we are doing that above.
| No linting issues found in the changes. | ||
| Review the changes and make sure they are as expected (correct indentation, no duplicate lines, etc). Edit the file again if necessary.""" | ||
| ) | ||
|
|
There was a problem hiding this comment.
Can you add a test case for delete as well?
Description
Deletion of code between specified range of lines is similar to insert. Moving code block is simply delete + insert calls.
How Has This Been Tested?
Unit tests and local testing.
Does this PR introduce a breaking change?
No.