Home Download Buy Blog Forum Support

Indent Guides

Re: Indent Guides

Postby iamntz on Fri Aug 05, 2011 4:11 am

WOW! Pure awesomeness! Thanks!

But... It seems it doesn't work on HTML nor JS files. (CSS & Py works ok though)
iamntz
 
Posts: 910
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Indent Guides

Postby ajpalkovic on Fri Aug 05, 2011 6:09 am

Yea, there's definitely a bug, but idk what it is. I'll debug it throughout the day tomorrow. I think it has something to do with switching views or something, but I'm not sure.
ajpalkovic
 
Posts: 142
Joined: Fri Jun 10, 2011 10:21 pm

Re: Indent Guides

Postby Anomareh on Fri Aug 05, 2011 7:28 am

https://gist.github.com/1127063

I hacked it a bit (emphasis on hack). Just got it to working well enough for myself.

Made a bunch of style changes inline with PEP 8.
Added an option to enable the active guide highlighting.
Stopped guides from being drawn in selections.
Edited the regex to not draw the guide if it's up against anything but the end of a line when flush_with_text is on.

Also I think I fixed the bug but no idea why it fixes it. I tracked it down to module reloading and grabbing multiple selections with ctrl+d. Sometimes when the module would get reloaded it wouldn't call refresh() until their was an actual file modification. Second, for some reason when grabbing multiple selections with ctrl+d the guides would disappear. I fixed it by forcing a refresh() if self.guides was empty after being loaded. Seems it gets emptied erroneously. No idea why though.
Anomareh
 
Posts: 222
Joined: Thu Oct 01, 2009 7:32 pm

Re: Indent Guides

Postby adzenith on Fri Aug 05, 2011 4:56 pm

I made a real repo for this plugin at https://github.com/SublimeText/IndentGuides. I'm going to work on incorporating all your changes hopefully sometime this weekend.
Thanks!
adzenith
 
Posts: 1216
Joined: Mon Oct 19, 2009 9:12 pm

Re: Indent Guides

Postby ajpalkovic on Fri Aug 05, 2011 5:29 pm

Eugh, I hate it when plugins stop working because someone added a new setting. Such a pain. Personally, I think it is really weird and annoying that most plugins in sublime default to being off. Why would I install a plugin if I didn't want to use it. Plugins should default to being on. </rant>

You need parentheses on line 166. You could have a situation like not True and False which is interpreted as (not True) and False but you want not (True and False) so that it gets in the if.

Also, I don't like that when I select text, all indent guides go away. I actually used that a good bit in my 76 space indent to select the correct text.
ajpalkovic
 
Posts: 142
Joined: Fri Jun 10, 2011 10:21 pm

Re: Indent Guides

Postby Anomareh on Fri Aug 05, 2011 8:52 pm

ajpalkovic wrote:Eugh, I hate it when plugins stop working because someone added a new setting. Such a pain. Personally, I think it is really weird and annoying that most plugins in sublime default to being off. Why would I install a plugin if I didn't want to use it. Plugins should default to being on. </rant>

It was 2 in the morning and I was just hacking a bit with what was there.

ajpalkovic wrote:You need parentheses on line 166. You could have a situation like not True and False which is interpreted as (not True) and False but you want not (True and False) so that it gets in the if.

That refresh only needs to be run when self.guides is empty and self.loaded is True. It was a quick hack to get it working around that odd bug I explained earlier.

ajpalkovic wrote:Also, I don't like that when I select text, all indent guides go away. I actually used that a good bit in my 76 space indent to select the correct text.

I'll play around with it a bit more and add it as an option and try and cleanup my mess a bit :s
Anomareh
 
Posts: 222
Joined: Thu Oct 01, 2009 7:32 pm

Re: Indent Guides

Postby ajpalkovic on Fri Aug 05, 2011 9:53 pm

Heh, yea, it's cool.

The thing I've noticed is that it can be a little slow. It's because of the way regions are done in sublime. What we end up doing is redrawing ALL of the guides every time I type or move the cursor in any way. That is causing lag. I think we need to either a: remove that option or b: move that code to run in a timer so it doesn't lag while i am typing. In a 5,000 line file, it might add like 20k regions to it. We are iterating through each of them every time and replace all the regions every time the selection changes.
ajpalkovic
 
Posts: 142
Joined: Fri Jun 10, 2011 10:21 pm

Re: Indent Guides

Postby adzenith on Sat Aug 06, 2011 6:52 am

If we could capture when the view changes, we could do it only in the current viewable area. Or if we could capture what changes in the buffer, we could only update lines that change.
Because neither of these things is possible at the moment, I just only edit small files. :P
Seriously though, a timer's probably a good idea. I might look into doing that over the weekend.
adzenith
 
Posts: 1216
Joined: Mon Oct 19, 2009 9:12 pm

Re: Indent Guides

Postby ajpalkovic on Sat Aug 06, 2011 7:04 am

There's a half decent implementation of a timer here (it executes a callback .1 seconds after the most recent call to on_sel_modified) https://github.com/ajpalkovic/SublimePl ... edFiles.py
ajpalkovic
 
Posts: 142
Joined: Fri Jun 10, 2011 10:21 pm

Re: Indent Guides

Postby iamntz on Sat Aug 06, 2011 7:51 am

Thanks for the update.

There is any way of setting the highlight color other than editing the theme file? Like a setting or something?
iamntz
 
Posts: 910
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 6 guests