One of the main reasons I like to work in Toad is the ability to collapse
regions to make complex queries or long scripts easier to manage and work with
– I can roll them up to a high level, and keep my bearings.
One annoyance however when working with collapsed regions is that regions auto
expand when you manually key SQL Statements above the collapsed region that
include single or double quoted, or comment characters such as /*
Here’s an example. Say your script looks like this:
select * from sys.objects where name =
–Region Test stuff
select top 5 *
select top 5 * from information_schema.columns
But you’re working with it collapsed like this:
(Note that the “Test Stuff” region is collapsed).
Now, I want to complete the SQL Statement above that region, so I start typing a
The result is that it immediately expands all the regions from here to the
bottom of the doc, and then of course marks it all red (i.e. the
(My problem isn’t with that per se – I understand why it would do
When I finish typing the statement however, I’m now left with every region
that was previously collapsed, being expanded:
I do understand why it behaves this way – because when I start typing that
opening quote there’s no way for Toad to know that I don’t intend
for those region statements to be part of the string, so it would be wrong to
leave them collapsed.
But what I really want it to do, when I’m finished typing my string and
key the closing quote is I want my regions returned to their previous state. All
the regions that were previously collapsed – I want collapsed again.
Thought on how to do this:
One option: keep track of the location of all the regions and their states in
some kind of memory structure. When a user types single quotes and it explodes
out the detail – keep the previous region expanded/collapsed states in
memory. When they close the quote and the script returns to normal, re-collapse
the regions that were previously collapsed using the values in memory.
I may be dreaming in terms of thinking that’s even remotely possible, but
my job is not to make it happen – just to point out things that hurt my