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

feat: Implement Step-by-Step Cairo Code Highlighting - Issue #124 #131

Merged
merged 11 commits into from
Apr 1, 2024

Conversation

melnikga
Copy link
Contributor

@melnikga melnikga commented Mar 27, 2024

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.

@melnikga melnikga changed the title feat: Implement Step-by-Step Cairo Code Highlighting - Issue #124 WIP: Implement Step-by-Step Cairo Code Highlighting - Issue #124 Mar 27, 2024
@melnikga melnikga changed the title WIP: Implement Step-by-Step Cairo Code Highlighting - Issue #124 feat: Implement Step-by-Step Cairo Code Highlighting - Issue #124 Mar 27, 2024
Copy link
Contributor

@barabanovro barabanovro left a 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:

  1. The code highlighter for Cairo is outdated (monaco-language-cairo is for Cairo v0). We need it to work with Cairo >=1.
  2. The comment shortcut is adding # but Cairo 1 uses //.
  3. You’ve set python as the languageID which isn't quite right for Cairo 1.
  4. Switching from Cairo to Sierra or CASM makes the highlighting vanish.
  5. The Type Casting example doesn't highlight Cairo segments for zero (0) Sierra statement.

@melnikga
Copy link
Contributor Author

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.

Copy link
Contributor

@barabanovro barabanovro left a comment

Choose a reason for hiding this comment

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

  1. Remove packages if you don't use them, for example, 'monaco-editor-webpack-plugin'.
  2. Remove console.log.
  3. Get the active Sierra statement index from casmToSierraMap instead of getting it from statement strings.
  4. Disable the highlighting feature when the user has edited the Cairo code to avoid confusion.

Copy link
Contributor

@barabanovro barabanovro left a comment

Choose a reason for hiding this comment

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

LGTM!

@barabanovro barabanovro merged commit 9192869 into walnuthq:main Apr 1, 2024
2 checks passed
@barabanovro barabanovro linked an issue Apr 2, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Implement Step-by-Step Cairo Code Highlighting
3 participants