Skip to content

Commit be31b36

Browse files
committed
A setting to ignore #regions #148
1 parent 14166e3 commit be31b36

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

CodeNav.Shared/Mappers/RegionMapper.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public static List<CodeRegionItem> MapRegions(SyntaxTree tree, TextSpan span, IC
2626
{
2727
var regionList = new List<CodeRegionItem>();
2828

29-
if (tree == null)
29+
if (tree == null ||
30+
!General.Instance.ShowRegions)
3031
{
3132
return regionList;
3233
}
@@ -178,8 +179,12 @@ private static string MapRegionName(SyntaxTrivia source)
178179
/// <returns></returns>
179180
public static bool AddToRegion(List<CodeRegionItem> regions, CodeItem item)
180181
{
181-
if (item?.StartLine == null) return false;
182-
182+
if (item?.StartLine == null ||
183+
!General.Instance.ShowRegions)
184+
{
185+
return false;
186+
}
187+
183188
foreach (var region in regions)
184189
{
185190
if (region?.Kind == CodeItemKindEnum.Region)

CodeNav.Shared/Options/General.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ public class General : BaseOptionModel<General>
4242
public int SortOrder { get; set; } = 0;
4343

4444
public bool UpdateWhileTyping { get; set; } = false;
45+
46+
public bool ShowRegions { get; set; } = true;
4547
}

CodeNav.Shared/ViewModels/OptionsWindowViewModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ public bool ShowHistoryIndicators
3535
set => SetProperty(ref _showHistoryIndicators, value);
3636
}
3737

38+
private bool _showRegions = true;
39+
40+
public bool ShowRegions
41+
{
42+
get => _showRegions;
43+
set => SetProperty(ref _showRegions, value);
44+
}
45+
3846
private bool _disableHighlight = false;
3947

4048
public bool DisableHighlight

CodeNav.Shared/Windows/OptionsWindow.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@
102102
Show the filter toolbar
103103
</CheckBox>
104104

105+
<CheckBox IsChecked="{Binding ShowRegions, Mode=TwoWay}" Margin="0,5">
106+
Show regions
107+
</CheckBox>
108+
105109
<CheckBox IsChecked="{Binding UseXMLComments, Mode=TwoWay}" Margin="0,5">
106110
Use XML comments for method tooltips
107111
</CheckBox>

CodeNav.Shared/Windows/OptionsWindow.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ private void OptionsWindow_Loaded(object sender, RoutedEventArgs e)
3131
UpdateWhileTyping = General.Instance.UpdateWhileTyping,
3232
Font = SettingsHelper.Font,
3333
BackgroundColor = General.Instance.BackgroundColor,
34-
HighlightColor = General.Instance.HighlightColor
34+
HighlightColor = General.Instance.HighlightColor,
35+
ShowRegions = General.Instance.ShowRegions,
3536
};
3637
}
3738

@@ -103,6 +104,7 @@ private void OkClick(object sender, RoutedEventArgs e)
103104
General.Instance.AutoLoadLineThreshold = ViewModel.AutoLoadLineThreshold;
104105
General.Instance.BackgroundColor = ViewModel.BackgroundColor;
105106
General.Instance.HighlightColor = ViewModel.HighlightColor;
107+
General.Instance.ShowRegions = ViewModel.ShowRegions;
106108

107109
General.Instance.Save();
108110

@@ -134,6 +136,7 @@ private void ResetClick(object sender, RoutedEventArgs e)
134136
General.Instance.UpdateWhileTyping = false;
135137
General.Instance.AutoLoadLineThreshold = 0;
136138
General.Instance.BackgroundColor = ColorHelper.Transparent();
139+
General.Instance.ShowRegions = true;
137140
General.Instance.Save();
138141

139142
SettingsHelper.Refresh();

0 commit comments

Comments
 (0)