views:

100

answers:

2

Hi, I am writing a macro, and I would like to determine if the current line where the cursor resides is a collapsed area or not. Can someone show me a way to do this?

+3  A: 

Sure:

return false

Seriously though - the cursor can't reside in a collapsed region - you always see it. Put the cursor inside a method, then collapse the method, and the cursor jumps into the method definition. Uncollapse the method and the cursor stays in the definition.

Edit------------------

Reading your comment, it seems like there are some resourecs you can use, but nothing that fits exactly what you need. You could try using Edit.StopOutlining to turn off all collapsing, then run through the Macro. You could also take a look at the sample Macro "OutlineCode" which collapses code - and then try and change it to uncollapse code. There's also a MSDN article on that.

Tom Ritter
Perhaps you could create a macro to detect if the cursor is in a collapsible region.
Tom, I don't think I explained myself very well. I have a macro that adds some standard logging statements to a method. When that macro is invoked, the method might be collapsed, or it may be open. Either way, the method must be open (uncollapsed) in order for the proper logging statements to be added. I need some way to ensure the method isn't collapsed. There is a Toggle Outlining Expansion, but I need some way to 'Toggle Off' for the current method the cursor resides on.
John
+1  A: 

So a workable solution for me is to turn off outlining expansion, have the macro do its magic and then turn auto-outlining expansion back on. Thanks for the help!

John