bsegraves / custom-folds

Atom plugin for defining custom markers for foldable regions.
MIT License
24 stars 9 forks source link

Add fold icon to gutter so you can click to fold region #7 #9

Closed marcel0ll closed 8 years ago

marcel0ll commented 8 years ago

I found a way to create a click event on the fold icon, but was unable to find a good place to add a call to it (_addClickEvent)

marcel0ll commented 8 years ago

With the last commit everything should be working. Now you can click on the gutter to close a region

bsegraves commented 8 years ago

Whoah, thanks a lot! Reviewing now.

bsegraves commented 8 years ago

The logic looks sound, unfortunately the click handler doesn't seem to work (at least with Atom 1.10.0).

$(gutter) on my system results in "VM38:1688 Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '[object HTMLDivElement]' is not a valid selector."

A potential solution might be to do a click handler on the document as a whole and check for the target to see if it's fold icon we created.

Another solution would be to dynamically add and remove click handlers for each fold icon.

Note that I initially thought it was working when I defined a foldable region without anything inside - just the start and end tags. But once I added a code in between the tags it no longer folded. My guess is that Atom's built-in folding code was being triggered for what it thought was a comment block.

marcel0ll commented 8 years ago

I had a similar bug with a non-code file. I will check what is going on, but here it is working perfectly

nheath commented 8 years ago

yessss! so glad to see this implemented.

bsegraves commented 8 years ago

Thanks so much for taking the time to do this!