diff --git a/src/FixMixedTabs/Impl/InformationBar.cs b/src/FixMixedTabs/Impl/InformationBar.cs index 044a42d..a427a30 100644 --- a/src/FixMixedTabs/Impl/InformationBar.cs +++ b/src/FixMixedTabs/Impl/InformationBar.cs @@ -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; @@ -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(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) @@ -204,6 +220,28 @@ private void Untabify(object sender, RoutedEventArgs e) } } + private void Fix(object sender, RoutedEventArgs e) + { + if (_textView != null) + { + Func action = _operations.Untabify; + if (!_textView.Options.GetOptionValue(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); diff --git a/src/FixMixedTabs/Impl/InformationBar.xaml b/src/FixMixedTabs/Impl/InformationBar.xaml index b13c452..2fd51f1 100644 --- a/src/FixMixedTabs/Impl/InformationBar.xaml +++ b/src/FixMixedTabs/Impl/InformationBar.xaml @@ -7,6 +7,7 @@ +