Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions src/FixMixedTabs/Impl/InformationBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public InformationBarMargin(IWpfTextView textView, ITextDocument document, IEdit
_telemetrySession = TelemetrySessionForPPT.Create(this.GetType().Assembly);

var informationBar = new InformationBarControl();
informationBar.Fix.Click += Fix;
informationBar.Tabify.Click += Tabify;
informationBar.Untabify.Click += Untabify;
informationBar.Hide.Click += Hide;
Expand Down Expand Up @@ -145,8 +146,23 @@ private void ShowInformationBar()
if ((!_isClosed) || _dontShowAgain)
return;

_isClosed = false;
ChangeHeightTo(27, false);
if (this.Content is InformationBarControl informationBar)
{
if (_textView.Options.IsOptionDefined<bool>(DefaultOptions.ConvertTabsToSpacesOptionId, false) == true)
{
informationBar.Fix.Visibility = Visibility.Visible;
informationBar.Tabify.Visibility = Visibility.Collapsed;
informationBar.Untabify.Visibility = Visibility.Collapsed;
}
else
{
informationBar.Fix.Visibility = Visibility.Collapsed;
informationBar.Tabify.Visibility = Visibility.Visible;
informationBar.Untabify.Visibility = Visibility.Visible;
}
_isClosed = false;
ChangeHeightTo(27, false);
}
}

private void ChangeHeightTo(double newHeight, bool instant)
Expand Down Expand Up @@ -204,6 +220,28 @@ private void Untabify(object sender, RoutedEventArgs e)
}
}

private void Fix(object sender, RoutedEventArgs e)
{
if (_textView != null)
{
Func<bool> action = _operations.Untabify;
if (!_textView.Options.GetOptionValue<bool>(DefaultOptions.ConvertTabsToSpacesOptionId))
{
action = _operations.Tabify;
}
PerformActionInUndo(() =>
{
_operations.SelectAll();
action();
});

this.CloseInformationBar(false);

_telemetrySession.PostEvent("VS/PPT-FixMixedTabs/Fix");
}
}


private void PerformActionInUndo(Action action)
{
ITrackingPoint anchor = _textView.TextSnapshot.CreateTrackingPoint(_textView.Selection.AnchorPoint.Position, PointTrackingMode.Positive);
Expand Down
1 change: 1 addition & 0 deletions src/FixMixedTabs/Impl/InformationBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Border BorderBrush="Silver" BorderThickness="0,0,0,2">
<DockPanel Background="Gainsboro" LastChildFill="False">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" DockPanel.Dock="Right">
<Button Name="Fix" Margin="5,0,0,0" Width="65" Height="22" Visibility="Collapsed">Fix</Button>
<Button Name="Tabify" Margin="5,0,0,0" Width="65" Height="22">Tabify</Button>
<Button Name="Untabify" Margin="5,0,0,0" Width="65" Height="22">Untabify</Button>
<Border Padding="15,0,0,0" />
Expand Down