locked
Outlining regions default collapsing does not seem to work RRS feed

  • Question

  • Hi,

    I am creating Visual Studio 2012 extension following MSDN Walkthrough: Outlining article (I am sorry for not providing link, this forum does not allow me) and all works as expected (I.e. I am able to create my own outlining regions) until I want my newly created outlining regions to collapse by default.

    What I do is changing following example code from the walkthrough from

    yield return new TagSpan<IOutliningRegionTag>
    (
      new SnapshotSpan(startLine.Start + region.StartOffset, endLine.End),
      new OutliningRegionTag(false, false, ellipsis, hoverText)
    );
    

    to

    yield return new TagSpan<IOutliningRegionTag> ( new SnapshotSpan(startLine.Start + region.StartOffset, endLine.End), new OutliningRegionTag(true, false, ellipsis, hoverText) );

    So basically I only change the first parameter (bool isDefaultCollapsed) of OutliningRegionTag constructor from 'false' to 'true' and I expect the region to be collapsed by default after it is created. Unfortunately my regions are still expanded and react only to manual collapse/expand by clicking the +/- symbols.

    Is my expectation wrong? Do I understand something wrong? Is there any other way to achieve what I want (i.e. having newly created outline regions collapsed on demand)?

    Thank you,

    Otakar Nieder 

    Sunday, December 27, 2015 8:25 PM

Answers

  • Hi DotNet Wang,

    thank you again for your reply. Your suggestion is definitely a way for collapsing region but not eactly what I am looking for. Anyway, I guess I finally found the ideal solution for my case.

    More can be found here:

    https://social.msdn.microsoft.com/Forums/en-US/b4daaf2e-78e3-4838-81e6-3c674f3bcca3/how-to-enumerate-collapsed-regions-in-the-vs2015-code-editor-window?forum=vsx

    It is for VS2015 but it seems that there should be no issues using the same approach in VS2012.

    Kind regards,

    Otakar Nieder

    • Marked as answer by lafarga Thursday, December 31, 2015 9:13 AM
    Thursday, December 31, 2015 9:13 AM

All replies

  • Hi lafarga,

    Try to set IsImplementation property to true.

    new OutliningRegionTag(true, true, ellipsis, hoverText)

    In addition, the code in walkthrough doesn't achieve full functionality. I suggest you download the source code of C# outline to make a deeper understanding of outlining.
    https://github.com/Skybladev2/C--outline-for-Visual-Studio

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 28, 2015 5:33 AM
  • Hi DotNet Wang,

    thank you for your response.

    Unfortunately using the true for IsImplementation parameter of OuliningRegionTag does not seem to have any effect on the collapsed state of the region after it is created.

    Thanks also for pointing me to the other outlining example. It definitely adds a bit more insight into the parsing and regions creating process but the outlining relevant code is basically the same and didn't get me any further in my effort.

    So my question unfortunately still remains. How to create an outlining region that is by default collapsed?

    If that question does not have answer, I actually can ask a different question that would help me move forwards. How to access existing outlining regions and change their collapsed/expanded state?

    Kind regards,

    Otakar Nieder

    Monday, December 28, 2015 2:41 PM
  • Hi lafarga,

    >>How to access existing outlining regions and change their collapsed/expanded state?

    You could use _DTE.ExecuteCommand to execute Toggle Outlining Expansion command.

    _DTE.ExecuteCommand("Edit.Outlining.ToggleOutliningExpansion");
    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 30, 2015 7:18 AM
  • Hi DotNet Wang,

    thank you again for your reply. Your suggestion is definitely a way for collapsing region but not eactly what I am looking for. Anyway, I guess I finally found the ideal solution for my case.

    More can be found here:

    https://social.msdn.microsoft.com/Forums/en-US/b4daaf2e-78e3-4838-81e6-3c674f3bcca3/how-to-enumerate-collapsed-regions-in-the-vs2015-code-editor-window?forum=vsx

    It is for VS2015 but it seems that there should be no issues using the same approach in VS2012.

    Kind regards,

    Otakar Nieder

    • Marked as answer by lafarga Thursday, December 31, 2015 9:13 AM
    Thursday, December 31, 2015 9:13 AM