-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add folding support to code blocks #12680
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
Conversation
Summary of ChangesHello @schultek, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the presentation of code blocks by introducing a new folding mechanism. Users can now define collapsible sections within their code snippets, making complex or lengthy examples easier to navigate and digest. The implementation includes both frontend styling for a clear visual experience and backend processing to interpret folding markers and generate the appropriate interactive HTML structure. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
This is only for demoing this feature and should be reverted before merge.
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.
Code Review
This pull request introduces an excellent feature for adding foldable sections to code blocks. The implementation is generally well-structured, using <details> elements for semantic HTML and a stack-based approach for parsing nested folds. However, I've identified a few critical and high-severity issues that will prevent the feature from working as intended. The CSS for indentation relies on an unsupported attr() function, which will break the visual layout. Additionally, there are a couple of off-by-one errors in the Dart logic for calculating folding ranges and constructing the components, which will result in incorrect folding behavior. My review includes specific suggestions to address these problems.
|
Visit the preview URL for this PR (updated for commit 3a26dcc): https://flutter-docs-prod--pr12680-feat-folding-code-block-dx916ymi.web.app |
c0fd150 to
f2d3abf
Compare
parlough
left a comment
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.
Overall looks great to me, thanks!
Also gives me some ideas of how to best extract the code block logic.
f2d3abf to
f6930d9
Compare
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.
Looks good to me, thanks @schultek!
Feel free to land this after removing the example usages from widgets.md. Consider adding one to the generated fwe.md page though.
0ff4667 to
3a26dcc
Compare
This adds support for defining folding ranges in any code block.
Folding ranges can be defined by specifying
foldableon the code block and using[*and*]lines in the code, and will be transformed to collapsible sections with a toggle marker and indicator line. Folding ranges can be nested. By default folding ranges are open, but can be set to initially closed using[* -.When using line numbers, the folding range markers and lines will be shifted to the right of the line numbers.