improve folding #1042

Closed
wants to merge 20 commits into from

4 participants

@nightwing
Ajax.org B.V. member

added special folding for lua, latex, markdown
enabled folding for several other modes
added ability to fold by double clicking on the gutter
+ some minor cleanup

@ajaxorg/liskov @gjtorikian

@mostafaeweda mostafaeweda commented on the diff Oct 17, 2012
lib/ace/mode/ruby.js
@@ -37,10 +37,12 @@ var Tokenizer = require("../tokenizer").Tokenizer;
var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var Range = require("../range").Range;
+var FoldMode = require("./folding/coffee").FoldMode;

Why would the ruby has coffee folding mode ?
Ruby may not follow the indentation rules as coffee --> I guess ruby must have its own folding rules

@nightwing
Ajax.org B.V. member

Unfortunately rules for Ruby blocks seem to be rather complex, and i couldn't make it work.
Using indentation is the next best thing, much better than no folding at all.
btw Sublime Text uses indentation for all languages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@gjtorikian

I continue to be completely baffled by how the fold modes work. I just can't wrap my head around it. It seems like it ought to be trivial--define a start regex, and an end regex, and that's it ! But no.... :(

Anyway, for that reason, I don't really feel comfortable reviewing this.

@bootstraponline

👍 The markdown folding is wonderful. It looks like there's no support for the alternate GitHub style code block ~~~.

~~~ { .ruby #is .valid }
puts 'ruby!'
~~~~
puts 'ruby!'

I recently added this to gollum. GitHub.com has supported it for a while.

@nightwing
Ajax.org B.V. member

It seems like it ought to be trivial--define a start regex, and an end regex, and that's it !
almost, you also need to use rather complex alghorithm to try filter out false positives based on indentation
https://github.com/textmate/textmate/blob/master/Frameworks/layout/src/folds.cc#L279

but even with that, markdown and latex foldings won't work.

@bootstraponline i didn't know about ~~~ blocks, i'll try to add that soon but support for nested blocks requires bigish changes to tokenizer, so it will take some time.

@gjtorikian

for the alternate GitHub style code block

Does ~~~ { .ruby #is .valid } render as <pre id="is" class="ruby valid">? This is the first time I've seen ~~~ over ```

but even with that, markdown and latex foldings won't work.

Yeah, I get that. My brain just has a hard time seeing how all the start/stop/block/keyword/first-level/second-level rules work. One day it'll click, but that day is not now 😿

@bootstraponline

@gjtorikian Only the first class is used on GitHub. {} is optional and ~~~ can be more than three. Here's the gollum implementation. Pandoc has a good write up of the syntax.

@nightwing nightwing closed this Nov 4, 2012
@academyofzhuang

The markdown folding doesn't work consistently for "#" and "="

# article 1
A Paragraph.
## level 2
A Paragraph.

# article 2
A Paragraph.

When I click the fold icon at the left of article one, I expect it to fold all lines till article 2. Current behavior is to fold all lines till level 2.

However, this works

article 1
======
A Paragraph.
level 2
--------
A Paragraph.

article 2
======
A Paragraph.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment