Skip to content

Add three new options for collapsing/outlining on file open#60743

Merged
davidwengier merged 14 commits intodotnet:mainfrom
davidwengier:DocumentCollapsingOptions
May 5, 2022
Merged

Add three new options for collapsing/outlining on file open#60743
davidwengier merged 14 commits intodotnet:mainfrom
davidwengier:DocumentCollapsingOptions

Conversation

@davidwengier
Copy link
Member

Fixes #60049
Fixes #44843

Options pane looks like this:
image

@davidwengier davidwengier requested a review from a team as a code owner April 14, 2022 06:28
@ghost ghost added the Area-IDE label Apr 14, 2022
bannerText: GetBannerText(regionDirective),
autoCollapse: autoCollapse,
isDefaultCollapsed: !options.IsMetadataAsSource));
isDefaultCollapsed: options.CollapseRegionsOnFileOpen));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the "Enter outlining mode" was equivalent to "Collapse regions on file open", but has been split to a separate option. The !options.IsMetadataAsSource wasn't doing anything here (it may as well have been true) because the code path for metadata as source uses the autoCollapse property which has the real logic (a few lines up from what GitHub shows here)


if (!workspace.Options.GetOption(FeatureOnOffOptions.Outlining, this.RoslynLanguageName))
{
outliningManager.Enabled = false;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the old "Enter outlining mode" would actually turn off outlining.

The diff for this file is probably best viewed with whitespace off.

<value>Prefer simplified object creation</value>
</data>
<data name="Collapse_imports_on_file_open" xml:space="preserve">
<value>Collapse Imports on file open</value>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See Mum, I remembered!!

bool ShowOutliningForDeclarationLevelConstructs = true,
bool ShowOutliningForCodeLevelConstructs = true,
bool CollapseRegionsWhenFirstOpened = true,
bool CollapseImportsWhenFirstOpened = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting. is that to match VB current bheavior?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the current VB and C# behaviour. Before this PR we didn't collapse usings, nor have an option for it.

@CyrusNajmabadi
Copy link
Contributor

Done with pass.

@davidwengier davidwengier enabled auto-merge (squash) May 4, 2022 10:50
@JoeRobich
Copy link
Member

Be sure to update the strings used by the Tools>Options search.
https://github.com/dotnet/roslyn/blob/main/src/VisualStudio/CSharp/Impl/VSPackage.resx#L202
https://github.com/dotnet/roslyn/blob/main/src/VisualStudio/VisualBasic/Impl/VSPackage.resx#L142

@davidwengier davidwengier merged commit e0de281 into dotnet:main May 5, 2022
@ghost ghost added this to the Next milestone May 5, 2022
@davidwengier davidwengier deleted the DocumentCollapsingOptions branch May 5, 2022 07:13
@Cosifne Cosifne modified the milestones: Next, 17.3 P2 May 31, 2022
@heku
Copy link

heku commented Aug 11, 2022

May I know is this PR already released in VS 17.3? I upgraded my VS up to date today, but I found the checkbox Collapse usings on file open is not working.

@davidwengier
Copy link
Member Author

If you can see the checkbox, then it's released :)

It's worth noting that VS remembers the outlining state for all files so if you change the checkbox you should delete the .suo file, or the .vs directory, and then check what happens when you open a file. Sorry I can't be sure which one, I'm not near a computer right now.

If you still have problems with it, please do log an issue with all of the details and I'll take a look.

@heku
Copy link

heku commented Aug 11, 2022

@davidwengier 👍 It works, great thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relax file collapsing on navigation for Source Link Add an option to collapse using section automatically

6 participants