Sublime Forum

Indent Guides

#21

[quote=“adzenith”]Do you have any other data you can give me? It’s hard for me to fix it if it works over here and I don’t know why it doesn’t work over there.
Thanks![/quote]

What do you want to know?

0 Likes

#22

It would be handy to include the contents of the console: it’ll confirm that the plugin was actually loaded, and any python exceptions will be reported there.

0 Likes

#23

startup, version: 2024 windows x64 channel: dev executable: /C/Program Files/Sublime Text 2/sublime_text.exe working dir: /C/Windows/system32 packages path: /C/Users/James.Brooks/AppData/Roaming/Sublime Text 2/Packages settings path: /C/Users/James.Brooks/AppData/Roaming/Sublime Text 2/Settings package /C/Program Files/Sublime Text 2/Pristine Packages/ActionScript.sublime-package is newer than the installed version (/C/Users/James.Brooks/AppData/Roaming/Sublime Text 2/Pristine Packages/ActionScript.sublime-package), running PackageSetup error parsing session: No data at: 0:0 PackageSetup returned: -1 scanning /C/Users/James.Brooks/AppData/Roaming/Sublime Text 2/Packages scanned /C/Users/James.Brooks/AppData/Roaming/Sublime Text 2/Packages catalogue loaded found 1 files for base name Default.sublime-theme found 2 files for base name Default (Windows).sublime-keymap found 1 files for base name Main.sublime-menu Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\comment.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\copy_path.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\delete_word.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\detect_indentation.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\duplicate_line.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\exec.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\find_under_expand.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\font.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\goto_line.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\indentation.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\kill_ring.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\mark.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\scroll.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\sort.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\swap_line.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\switch_file.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\transform.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\transpose.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\Default\trim_trailing_white_space.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\User\indent_guides.py Reloading plugin C:\Users\James.Brooks\AppData\Roaming\Sublime Text 2\Packages\User\insert_nums.py loading bindings theme loaded app ready scanning /X/tropicalwarehouse.co.uk loaded 918 snippets

0 Likes

#24

Clearly it appears to be loading… and you’ve got the option to enable it set in your user file prefs…
Can you type the following in the console and tell me what comes out? I just want to confirm that the settings have managed to make it into this view.

print(view.settings().get("show_indent_guides"))
0 Likes

#25

[quote=“adzenith”]Clearly it appears to be loading… and you’ve got the option to enable it set in your user file prefs…
Can you type the following in the console and tell me what comes out? I just want to confirm that the settings have managed to make it into this view.

print(view.settings().get("show_indent_guides"))

:open_mouth:

It returned false, but then I realised I put the options in the wrong file…

Sorry about that!

0 Likes

#26

Sorry to revive a slightly older thread but I’m having trouble installing this plugin on the portable version of Sublime.

Can someone please give me a (quick) “installation guide for dummies”? (Yes I really have spent time trying and have RTFM :smiley:)

Many thanks

0 Likes

#27
  • Download the source file from the link in the first post.

  • In Sublime Text 2, go to Preferences>Browse Packages…

  • Put the file you downloaded in Packages/User/.

  • In Sublime Text 2, open up the file you downloaded. It has instructions for lines to add to your user file prefs. If you don’t add these lines to that file, nothing will happen (to get to your user file prefs, go to Preferences>User File Prefs).

Let me know if it doesn’t work!

0 Likes

#28

Today I got to work on a clusterfuck of a file with a 76 space indent at one point (38 tabs).
As such, I modified the indent guides plugin a little bit so that it can also highlight the current indent guide.
The idea is that if my cursor is at column 4, all of the indent guides on column 4 are highlighted a slightly different color.
This is super useful if you are trying to balance tags or something, just click before a tag, and scroll down, following the highlighted indent guide.
The modified file is here: github.com/ajpalkovic/SublimePl … _guides.py

0 Likes

#29

Nice work! (sorry you have to edit such files, though).
Want to send me a pull request and I’ll integrate it into my repo?
Thanks!

0 Likes

#30

Hmm, idk, it seems to stop working for me every now and then. I have no clue why. It’s a really hard thing to debug because I can add a print statement, but then it reloads the plugin and starts working again. Eugh.

But yea, I didn’t fork your repo, so the diff of the file in mine is just gonna be 100% insertions, so it wouldn’t merge cleanly. In other words, it’s prolly either just to copy and paste it in and look at the diff with git diff.

0 Likes

#31

WOW! Pure awesomeness! Thanks!

But… It seems it doesn’t work on HTML nor JS files. (CSS & Py works ok though)

0 Likes

#32

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.

0 Likes

#33

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.

0 Likes

#34

I made a real repo for this plugin at github.com/SublimeText/IndentGuides. I’m going to work on incorporating all your changes hopefully sometime this weekend.
Thanks!

0 Likes

#35

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.

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.

0 Likes

#36

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

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.

I’ll play around with it a bit more and add it as an option and try and cleanup my mess a bit :s

0 Likes

#37

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.

0 Likes

#38

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. :stuck_out_tongue:
Seriously though, a timer’s probably a good idea. I might look into doing that over the weekend.

0 Likes

#39

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) github.com/ajpalkovic/SublimePl … edFiles.py

0 Likes

#40

Thanks for the update.

There is any way of setting the highlight color other than editing the theme file? Like a setting or something?

0 Likes