-
Notifications
You must be signed in to change notification settings - Fork 131
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
code-folding vs. comment-folding #121
Comments
Idea No. 1: use different prefixes We could use different prefixes to differentiate code- from comment-folding. Let's assume we have a prefix like Hint: all examples use coffee-script syntax. Example: single-line comment-folding
Example: multi-line comment-folding
Example: single-line code-folding
Example: multi-line block-comment code-folding
Pros:
Cons:
|
Idea No. 2: Mark the start and stop of the segment to fold with different marks We could use one prefix to mark the start of the segment to fold and a different one to stop folding. Let's assume we have a start-mark like Hint: all examples use coffee-script syntax. Example: single-line comment-folding
Example: in block-comment comment-folding
Example: single-line code-folding
… Example: single-line code-folding
Example: multi-line block-comment code-folding
Pros:
Cons:
|
Idea No. 3: Provide a code-folding feature with a smart end-of-fold-detection. This idea could be combined with a unique prefix as in the code-folding part of Idea (1). So the implementation could be enhanced as follows:
As a result we could have the following behavior, assuming we use Hint: all examples use coffee-script syntax. Example 1:
Example 2:
Example 3 (a single comment)
Pros:
Cons:
Suggestions:
|
Idea No.4: Never fold code It could be a bad idea to fold areas that include code. Folded areas should not hide code (or any other information) from the readers eyes. It's not the authors task to decide what's important to the reader and what not … Pros:
Cons:
Suggestion:
|
@achingbrain + @kmdavis and all the others are welcome to bash this topic … 💥 … |
… last updated: 09/18/2013, 07:00 PM, +0100 CEST |
The idea behind my original pull request was to be able to hide code, so I think it would be a shame to see that go away. Imports and the like are dull and distract the reader from the interesting bits. I also wanted "private" methods to be not immediately visible (although still available for the interested reader) - I know this is not strictly inline with the idea of literate programing but I think the tradeoff for readability is worth it. I'm not a big fan of the idea of having open-folding-section and close-folding-section comments. I think just "this comment documents the following code" is enough - if that comment decides to hide the following code, so be it. The next comment encountered should say something useful about the code following it, so it's enough to end the folding block. If you feel you're having to contort your comments to un-hide a block, perhaps you should instead write something useful in your comment as to why the next bit of code deserves the reader's attention ;) |
Phew, good to know that my last change to the master's HEAD, didn't change the intended behavior ! 😁 … I agree with your intention, but I've also found several use cases (I'll show them later, if you want to) where too much code was hidden (eg. spanning if- and else-statements and the [falsely] undocumented following method). So we still need a better way control this behavior. And what if I really just want to fold an overlong comment and nothing else ? |
I'm going to make a break for today and watch back tomorrow … bye … 👋 |
The current implementation offers the ability to fold comments by using a language-dependent prefix called
foldPrefix
in the comment to collapse.It's somehow confusing, as one could think only the comment gets folded, but actually the whole segment including all the code that follows the comment, up to but not including the next comment gets folded. The current “excuse” for this behavior are use cases, like hiding unimportant code as in node.js-imports, i.e.:
It's time to conceive ideas on how to optimize the current implementation, and we encourage you to comment on that. The first ideas follow this comment.
The text was updated successfully, but these errors were encountered: