Sublime Forum

[Bug] Bracket highlighting doesn't work over large distances

#1

I have noticed this specifically in PHP and on OSX but my guess is it is a global issue for ST2. (And yes I’m using inbuilt functionality, not the BracketsHighlighter plugin.)

If I have the following code:

if ($condition) {
	// ...bunch of code...
}

If the ‘bunch of code’ stuff goes over maybe 100 lines (or some large amount of lines that goes over a-screen-height-and-a-bit worth of lines) then if you place the cursor next to the opening or closing bracket the matcher/highlighter appears to look like it’s working. Indentation guides highlight to the correct level, and the bracket has the underline. Great - but now I want to scroll up or down to the matching bracket to see where it was but leave my cursor next to the other bracket (because I’m going to want to insert here n a bit and just wanted to see if the closing bracket I’m on is for the right ‘if’ (say I have a load of nested 'if’s)). As I scroll everything looks like it works, until the bracket my cursor is next to is maybe 5 or so lines outside of the viewport, and then all of this highlighting stops. The matching bracket is not underlined and my indentation guides stop being highlighted as the correct indentation level. If I fold some code in betwene so that the brakctes are on the same screen or near enough to it, then the behaviour is correct, it’s just if there’s some scrolling involved.

My guess is that maybe for optimisation/resources purposes you kill the cursor when it’s far enough out of the viewport, but this has the unfortunate effect of also killing this highlighting and bracket matching.

I can make an exemplary video if you’d like. Hopefully it makes sense though.

Edit:

Just seen update to 2191 and can confirm it’s still present.
There also appears to be another bug where the brackets don’t match sometimes. This is likely due to my PHP code not being properly recognised by the parser (it is 100% valid PHP though!), and will be hard to debug what’s going on there.

0 Likes

#2

Hmm I take it back, the bracket does get highlighted as I wanted (I just missed it). But there’s still the bug with indent guides. In fact it’s not justa bug with highlighting the guides, depending on the file you have they sometimes even disappear! But the disappearing act only appears to be an issue if there’s a load of whitespace - probably because these lines themselves are not indented:




Code is basically the below but with a lot more blank lines:

<?php
	if (1) {
		if (2) {
			// some code

			// that's long

			// really long

			// you call that long?

			// this is long!
		}
	}
0 Likes

#3

Take a look at http://www.sublimetext.com/forum/viewtopic.php?f=3&t=2311&start=0

For your use case, IMHO using ctrl+m is way better than scrolling the view to find the highlighted bracket.
Is ctrl+m working for you ?

0 Likes

#4

[quote=“bizoo”]Take a look at http://www.sublimetext.com/forum/viewtopic.php?f=3&t=2311&start=0

For your use case, IMHO using ctrl+m is way better than scrolling the view to find the highlighted bracket.
Is ctrl+m working for you ?[/quote]

A-ha, thanks for that. I did do a cursory search of the forum, but there’s waaaaay too many posts about BracketHighlighter that spam up the results for the core bracket matching stuff.

Yes ctrl+m works, and I use it a lot, but sometimes I don’t want it to jump per se, but instead I need to look at where I’m going, and sometimes I want to leave the cursor where it is (okay ctrl + m twice does that to an extent, but still. Dunno, it’s just caught me a few times.

The character limit certainly explains why in one occasion (my example with a bunch of newlines) it’ll work fine over many lines, and in others (a PHP function with actual code) it’ll break in only a few lines of code. Oh well, at least I know now, as much as I’d like the limit to be increased…

0 Likes