Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an edit magic command #942

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

IlyasKhallouki
Copy link

Added %edit to allow the user to edit the last code submitted by OI.
The code is saved in a temp file with its extension matching the language. When the user is done editing it, the code gets saved in interpreter.messages.

Pre-Submission Checklist :

  • I have included relevant documentation updates (stored in /docs)
  • I have read docs/CONTRIBUTING.md
  • I have read docs/ROADMAP.md

OS Tests :

  • Tested on Windows
  • Tested on MacOS
  • Tested on Linux

@IlyasKhallouki
Copy link
Author

@KillianLucas Can you please give an update on this.

@Notnaton Notnaton mentioned this pull request Jan 22, 2024
10 tasks
@KillianLucas
Copy link
Collaborator

Hi @Eliaskhal! Thanks for updating the PR, I think a magic command is a fantastic addition to OI.

From first glance I'm not sure if this would work, it looks like it appends the new code block to interpreter.messages. I think the edit command will need to:

  1. Retrieve the file extension from self.computer.terminal.get_language("language").file_extension — instead of a custom map at the top. This makes it work with custom languages too.
  2. Insert the code into the code block that it's editing, not append it as a new code block.
  3. Display the code to the user and prompt if they want to run it (y/n).
  4. Use self.computer.run("language", "code") to run the code.

I'm happy to merge once this becomes a higher priority, then make those changes. If you can make those changes @Eliaskhal, I can credit you fully for the %edit command and get it into the update coming out this weekend! Great work either way, this is seriously such an awesome feature.

@IlyasKhallouki
Copy link
Author

Hey @KillianLucas, thank you for your reply. I will work on adding the features you mentioned. Thank you

@KillianLucas
Copy link
Collaborator

Hey @Eliaskhal! Let me know if you want to move make those changes, otherwise I'm happy to take a crack at it. Great work again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants