@fml2 said in Jumping between matching brackets is not idempotent:
Is it the intended behaviour of Notepad++?
That’s kind of the edge case condition, which probably wasn’t thought about too much. Notepad++ intentionally designed the brace matching so that whether your caret was on the left or the right of the brace-type character, when it went to the matching pair, it always puts the caret before that character. But that means when it gets moved between the two different opening braces, it’s before one and after the other… and because Notepad++ is processing the bytes in the order it finds them (ie, in Western cases where N++ works best, left-to-right), that means that it notices the caret is after the first brace, before it has a chance to notice it’s also before the second brace.
If you have the brace-highlighting turned on, you can tell which brace-pair Notepad++ thinks your caret position is associated with by which are highlighted. Here are screenshots of the highlights for each of the brace-adjacent caret positions, from left to right:
6eb029a2-9ef2-4f23-b3ca-eb2fefa57e68-image.png df0226af-4f73-4494-b88e-ab443d200194-image.png 8b20bba2-5e3e-4660-b49a-3fd46e834261-image.png f07cb269-31f9-4664-b625-5b2cea433edb-image.png 97c5bec2-e46b-4468-92b3-c24257c621c6-image.png 84eeb00a-aeca-48be-b61a-f2792897a78f-image.png 5fd69989-c036-4500-be55-abb337a03df4-image.pngBecause 4 and 5 both highlight the inner (...). the brace-match from there will take you to the before the opening (, at condition 2. But in condition 2, the pair that Notepad++ sees as active is [...], so the brace match from there will take you to condition 6, and from 6 will go to 1 (because it’s before the [)
The behavior borders on a bug… but I’m not sure there’s 100% agreement on which pair should be active and where the brace match should go in each condition, and thus I don’t know that it makes more sense to confuse people by “fixing” it to your interpretation, when it would then subvert years of expected Notepad++ behavior.