Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Added functionality for moving code block and deleting code block. - #13

Closed
RajWorking wants to merge 7 commits into
mainfrom
rj/move_code_blk
Closed

Added functionality for moving code block and deleting code block.#13
RajWorking wants to merge 7 commits into
mainfrom
rj/move_code_blk

Conversation

@RajWorking

Copy link
Copy Markdown
Member

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.

@RajWorking
RajWorking requested review from ryanhoangt and xingyaoww and removed request for xingyaoww November 16, 2024 18:23

@ryanhoangt ryanhoangt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread .gitignore Outdated
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
poetry.lock

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add lock file into version control, similar to OH codebase, for consistency and reproducibility.

Comment thread openhands_aci/editor/editor.py Outdated
raise EditorToolParameterMissingError(command, 'new_str')
return self.insert(_path, insert_line, new_str, enable_linting)
elif command == 'delete':
if not lines_range:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking should we raise error here or delete the whole file content

Comment thread openhands_aci/editor/editor.py Outdated
return self.delete(_path, lines_range)
elif command == 'move_code_block':
if not lines_range:
raise EditorToolParameterMissingError(command, 'lines_range')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar here

Comment thread openhands_aci/editor/editor.py Outdated
"""
Deletes text content in file from the given range.
"""
try:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

@ryanhoangt ryanhoangt Nov 17, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do validation for the command to make sure path is not a directory? (And maybe a test case for it)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."""
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test case for delete as well?

@neubig neubig closed this Dec 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants