Home Download Buy Blog Forum Support

BracketHighlighter2 BETA Branch

Re: BracketHighlighter2 Alpha Branch

Postby iamntz on Tue Oct 30, 2012 6:22 am

Cool, thanks for explanations. ;)
iamntz
 
Posts: 898
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: BracketHighlighter2 Alpha Branch

Postby iamntz on Sun Nov 04, 2012 8:54 am

I kinda found another bug! :mrgreen:
So, let's say we have this snippet:

Code: Select all
          <?php for ( $i=0; $i < 5; $i++ ) { ?>
           
          <?php } ?>


The bug is that { and } doesn't highlight correctly (only as invalid), although if I press ctrl+m (to jump to pair bracket) will jump correctly.

This is not related to my custom settings of the plugin (i removed everything and act the same).
iamntz
 
Posts: 898
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: BracketHighlighter2 Alpha Branch

Postby facelessuser on Sun Nov 04, 2012 2:42 pm

iamntz wrote:I kinda found another bug! :mrgreen:
So, let's say we have this snippet:

Code: Select all
          <?php for ( $i=0; $i < 5; $i++ ) { ?>
           
          <?php } ?>


The bug is that { and } doesn't highlight correctly (only as invalid), although if I press ctrl+m (to jump to pair bracket) will jump correctly.

This is not related to my custom settings of the plugin (i removed everything and act the same).


Mine highlights "{" and "}" as invalid (which I would expect, since "{" and "}" are not matched between the "<?php ?>" tags, it breaks the valid match rules). And cannot jump between the "{}" brackets either because they are invalid. This is the case for ctrl+m and BH2s jump between brackets method for me as well. ctrl+m uses ST2s algorithm. BH2 uses its own. I provide example keymaps to use BH2's version.

Now Ctrl+m was able to match PHP angles in the last PHP group, but not in the first. BH2's match did not match either. BH2 is very consistent when using its algorithm. ST2 seems like it is not.

Are you able to post more code? Because I could not reproduce what you described with just what you posed above. As you can see my description seems different than yours.
facelessuser
 
Posts: 1548
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter2 Alpha Branch

Postby iamntz on Sun Nov 04, 2012 5:38 pm

There is no need for more code because it seems that everything that match follow this pattern (more or less) doesn't work:
Code: Select all
< { >

< }>


I made a short movie here:
http://img.iamntz.com/jing/2012-11-04_1918.swf

with settings off (including those PHP tags):
http://img.iamntz.com/jing/2012-11-04_1924.swf
(also, at the end of the movie i enabled my settings & tried to use other brackets)

Green is ok, red is invalid. Pink is... i have no clue what (or why) is pink in that context!
iamntz
 
Posts: 898
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: BracketHighlighter2 Alpha Branch

Postby facelessuser on Sun Nov 04, 2012 8:28 pm

Pink is invalid syntax (sytax highlighter; not plugin related).

I am still confused. If I showed you this, I think we would both agree the curly should not be matched because what you really have is two broken curly pairs. This is invalid bracket pairs.:

Code: Select all
({)(})


This should match fine:
Code: Select all
({})({})


What you are showing me is the equivalent is it not?
Code: Select all
<?php { ?><?php } ?>


or

Code: Select all
<{><}>


Everything is generalized in BH2. It starts matching pairs and resolving them until it comes to the closest one surrounding the cursor. Isn't this what it is doing? You just have (by the generalized algorithms view) dangling curly brackets between valid angle brackets.

Now what you are wanting is some special case for PHP (which makes sense), but keep in mind BH1 couldn't resolve these issues either, and ST2 doesn't resolve them well either (if at all). HTML tags don't have this issue because they are a special case. In HTML, we just find the surrounding angles (which will always be a valid match if the tag is formatted correctly), and if they are part of a tag, we search the buffer for tags only (this is why it doesn't get confused resolving other brackets in between). But this is done with a special post_match BH plugin.

Here is another case that BH2 cannot resolve (C/C++ code). Which opening curly should it match to the closing?:

Code: Select all
#if (SOME_SWITCH)
if (some_condition) {
#else
if (some_other_condition) {
#endif
    dosomething();
}


There are some cases that BH is not going to be able handle very well. And the amount of code to tackle these issues can be quite a bit. Now PHP might be able to be resolved much easier than the C problem. I won't touch the C problem at all. But maybe in the future I can come up with a PHP solution (maybe).

Now in regards to ctrl+m finding different brackets than BH, this is because ST2 uses a different algorithm than BH2. I can make the "jump between brackets" BH command work more like ctrl+m, but it will still be using BH2's algorithm to match brackets. Currently BH2 has two separate "jump between brackets" commands. One jumps left, the other jumps right. ST2 just toggles between the two.
facelessuser
 
Posts: 1548
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter2 Alpha Branch

Postby iamntz on Sun Nov 04, 2012 8:57 pm

This is invalid bracket pairs.
Code: Select all
({)(})



Agree, but there are some languages (PHP, probably coldfusion) that are using this kind of stuff (loops, conditions) mixed with html code.

This make the plugin or the editor less awesome? Hell no! Is just a thing that would be nice to have. If is too much trouble, let it go, focus on more important stuff, i will survive. :D

Btw, as a totally non-related thing, i just realized that most used addons to sublime are: Soda theme, BH and emmet/zen. :mrgreen: :geek:
iamntz
 
Posts: 898
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: BracketHighlighter2 Alpha Branch

Postby facelessuser on Sun Nov 04, 2012 9:48 pm

I agree. Better PHP support would really be nice to have. It is one of those things that I have stored in the back of my mind to hopefully resolve some time. Sadly it is not on the top of my list. I really have only two maybe three things left I need to get knocked out. As you can see by the recent lull I have been taking a little break after the non-stop BH code-athon. I needed to step away from it for a little. Especially since it seems pretty stable, I felt okay about that. I have been side tracked by a couple of side projects.

The last things I have on my list are:
- A reasonable way to swap brackets (specifically swap out what gets highlighted with something else), with some functionality similar to wrapping (definable regions to highlight, and definable tabstops)
- Possibly a way to define a sub bracket search to only be searched of a scope (someone made a request to search php strings for HTML tags and I am looking into allowing certain non-scope brackets to be defined that are only searched for inside scope-brackets - such as strings).
- xeno-by's request to have a high visibility mode
facelessuser
 
Posts: 1548
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter2 Alpha Branch

Postby iamntz on Mon Nov 05, 2012 4:47 am

// dreaming mode: on
Don't know if you ever saw xcode bracket highlight, but when cursor touch a bracket, both brackets will kinda... jump (you can see it in action here). Sure, Xcode is dumb and will only do this then stop highlight at all (unless you touch again brackets), which kinda sucks.

Also, when you hover the bracket on the gutter, will sort of fade out the content of the outer brackets (here).

Not a big Xcode fan (in fact i hate it) but i think it's the nicest thing that anyone can steal pay tribute to (because, we all know, apple never steals, they only pay tributes!) :D

I'm pretty sure that these are some limitation of ST, that's why i used dream mode :mrgreen:
// dreaming mode: off
iamntz
 
Posts: 898
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: BracketHighlighter2 Alpha Branch

Postby facelessuser on Mon Nov 05, 2012 5:09 pm

iamntz wrote:// dreaming mode: on
Don't know if you ever saw xcode bracket highlight, but when cursor touch a bracket, both brackets will kinda... jump (you can see it in action here). Sure, Xcode is dumb and will only do this then stop highlight at all (unless you touch again brackets), which kinda sucks.

Also, when you hover the bracket on the gutter, will sort of fade out the content of the outer brackets (here).

Not a big Xcode fan (in fact i hate it) but i think it's the nicest thing that anyone can steal pay tribute to (because, we all know, apple never steals, they only pay tributes!) :D

I'm pretty sure that these are some limitation of ST, that's why i used dream mode :mrgreen:
// dreaming mode: off


There are a lot of things I would love to do if the API would let me. Sadly it won't let me do everything I would like.

The second demo is essentially what xeno-by wants. I can't do it like that though (regions sizes are limited by actual code text, so no perfect boxes, just text regions, and it kills syntax highlighting when with the region overlaid; also, can't trigger on hover events, so must make a toggle keybinding etc.). But if you really want to briefly use a high visibility mode, I can see how it would be useful which is why I have it on my list.
facelessuser
 
Posts: 1548
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter2 Alpha Branch

Postby facelessuser on Mon Nov 12, 2012 3:20 am

Update:
-Added high visibility mode (a mode that can be toggled to make bracket extent clearly visible). Essentially it just highlights the entire bracket block. It isn't meant to be run all the time, mainly just for times where you really need to see the extent of the the bracket block very clearly.

An example done in different styles.
Image

High visibility mode uses one highlight style for all brackets, but it inherits the brackets icons, and can optionally inherit the color as well.


The other update is one that will affect your settings file. I changed the find_in_sub_search in the bracket definitions to be a string variable instead of a boolean. So do this to all of the bracket definitions in your User settings file if they have this setting:

    // Change this
"find_in_sub_search": true,

// To this
"find_in_sub_search": "true",


Now find_in_sub_search can be set to "true", "false", "only".

BracketHighlighter is officially bumped to BETA status. There should be no more settings format changes now that this is in BETA.

The last and only feature on my list is the bracket swapping.
facelessuser
 
Posts: 1548
Joined: Tue Apr 05, 2011 7:38 pm

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 14 guests