Skip to content

Commit

Permalink
A setting to ignore #regions #148
Browse files Browse the repository at this point in the history
  • Loading branch information
sboulema committed Mar 4, 2024
1 parent 14166e3 commit be31b36
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
11 changes: 8 additions & 3 deletions CodeNav.Shared/Mappers/RegionMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public static List<CodeRegionItem> MapRegions(SyntaxTree tree, TextSpan span, IC
{
var regionList = new List<CodeRegionItem>();

if (tree == null)
if (tree == null ||
!General.Instance.ShowRegions)
{
return regionList;
}
Expand Down Expand Up @@ -178,8 +179,12 @@ private static string MapRegionName(SyntaxTrivia source)
/// <returns></returns>
public static bool AddToRegion(List<CodeRegionItem> regions, CodeItem item)
{
if (item?.StartLine == null) return false;

if (item?.StartLine == null ||
!General.Instance.ShowRegions)
{
return false;
}

foreach (var region in regions)
{
if (region?.Kind == CodeItemKindEnum.Region)
Expand Down
2 changes: 2 additions & 0 deletions CodeNav.Shared/Options/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ public class General : BaseOptionModel<General>
public int SortOrder { get; set; } = 0;

public bool UpdateWhileTyping { get; set; } = false;

public bool ShowRegions { get; set; } = true;
}
8 changes: 8 additions & 0 deletions CodeNav.Shared/ViewModels/OptionsWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ public bool ShowHistoryIndicators
set => SetProperty(ref _showHistoryIndicators, value);
}

private bool _showRegions = true;

public bool ShowRegions
{
get => _showRegions;
set => SetProperty(ref _showRegions, value);
}

private bool _disableHighlight = false;

public bool DisableHighlight
Expand Down
4 changes: 4 additions & 0 deletions CodeNav.Shared/Windows/OptionsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
Show the filter toolbar
</CheckBox>

<CheckBox IsChecked="{Binding ShowRegions, Mode=TwoWay}" Margin="0,5">
Show regions
</CheckBox>

<CheckBox IsChecked="{Binding UseXMLComments, Mode=TwoWay}" Margin="0,5">
Use XML comments for method tooltips
</CheckBox>
Expand Down
5 changes: 4 additions & 1 deletion CodeNav.Shared/Windows/OptionsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ private void OptionsWindow_Loaded(object sender, RoutedEventArgs e)
UpdateWhileTyping = General.Instance.UpdateWhileTyping,
Font = SettingsHelper.Font,
BackgroundColor = General.Instance.BackgroundColor,
HighlightColor = General.Instance.HighlightColor
HighlightColor = General.Instance.HighlightColor,
ShowRegions = General.Instance.ShowRegions,
};
}

Expand Down Expand Up @@ -103,6 +104,7 @@ private void OkClick(object sender, RoutedEventArgs e)
General.Instance.AutoLoadLineThreshold = ViewModel.AutoLoadLineThreshold;
General.Instance.BackgroundColor = ViewModel.BackgroundColor;
General.Instance.HighlightColor = ViewModel.HighlightColor;
General.Instance.ShowRegions = ViewModel.ShowRegions;

General.Instance.Save();

Expand Down Expand Up @@ -134,6 +136,7 @@ private void ResetClick(object sender, RoutedEventArgs e)
General.Instance.UpdateWhileTyping = false;
General.Instance.AutoLoadLineThreshold = 0;
General.Instance.BackgroundColor = ColorHelper.Transparent();
General.Instance.ShowRegions = true;
General.Instance.Save();

SettingsHelper.Refresh();
Expand Down

0 comments on commit be31b36

Please sign in to comment.