-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat: Implement Step-by-Step Cairo Code Highlighting - Issue #124 #131
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on the PR! A few fixes are required:
- The code highlighter for Cairo is outdated (
monaco-language-cairo
is for Cairo v0). We need it to work with Cairo >=1. - The comment shortcut is adding
#
but Cairo 1 uses//
. - You’ve set
python
as the languageID which isn't quite right for Cairo 1. - Switching from Cairo to Sierra or CASM makes the highlighting vanish.
- The Type Casting example doesn't highlight Cairo segments for zero (0) Sierra statement.
Due to the fact that the monaco editor does not support the Cairo 1 syntax, and in principle there is no library that would provide the opportunity to add Cairo to monaco, I decided to write my own config file to add a custom language. I think this is the most optimal solution at the moment, as it makes it possible to customize the language according to its development and not depend on a third-party library, which may not be updated for a long time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Remove packages if you don't use them, for example, 'monaco-editor-webpack-plugin'.
- Remove console.log.
- Get the active Sierra statement index from casmToSierraMap instead of getting it from statement strings.
- Disable the highlighting feature when the user has edited the Cairo code to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
To solve this problem, I decided to change the code editor, because sceditor is difficult to modify. I chose Monaco Editor as the new code editor, it already has built-in functions for highlighting lines. Moreover, this is the best solution if you want to add new features to the editor in the future.