From 141440e47fdf81b2811c76683b426e64f6c01399 Mon Sep 17 00:00:00 2001 From: pvasilek Date: Wed, 27 Nov 2019 20:31:48 +0200 Subject: [PATCH] Fixes #1812 --- ILSpy/Commands/DecompileInNewViewCommand.cs | 2 ++ ILSpy/MainWindow.xaml.cs | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ILSpy/Commands/DecompileInNewViewCommand.cs b/ILSpy/Commands/DecompileInNewViewCommand.cs index 5f4c137fc..e1e49ab79 100644 --- a/ILSpy/Commands/DecompileInNewViewCommand.cs +++ b/ILSpy/Commands/DecompileInNewViewCommand.cs @@ -62,9 +62,11 @@ namespace ICSharpCode.ILSpy.Commands { if (nodes.Length == 0) return; + var title = string.Join(", ", nodes.Select(x => x.ToString())); DockWorkspace.Instance.Documents.Add(new ViewModels.DecompiledDocumentModel(title, title) { Language = MainWindow.Instance.CurrentLanguage, LanguageVersion = MainWindow.Instance.CurrentLanguageVersion }); DockWorkspace.Instance.ActiveDocument = DockWorkspace.Instance.Documents.Last(); + MainWindow.Instance.SelectNodes(nodes); MainWindow.Instance.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (Action)delegate { DockWorkspace.Instance.GetTextView().DecompileAsync(MainWindow.Instance.CurrentLanguage, nodes, new DecompilationOptions()); }); diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs index 441abd5fd..67b278b89 100644 --- a/ILSpy/MainWindow.xaml.cs +++ b/ILSpy/MainWindow.xaml.cs @@ -117,10 +117,10 @@ namespace ICSharpCode.ILSpy }; DockWorkspace.Instance.LoadSettings(sessionSettings); - InitializeComponent(); - DockWorkspace.Instance.InitializeLayout(DockManager); + DockWorkspace.Instance.PropertyChanged += filter_DockWorkspace_PropertyChanged; + sessionSettings.FilterSettings.PropertyChanged += filterSettings_PropertyChanged; @@ -131,6 +131,17 @@ namespace ICSharpCode.ILSpy this.Loaded += MainWindow_Loaded; } + private void filter_DockWorkspace_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == "ActiveDocument") { + if ((sender as DockWorkspace).ActiveDocument is DecompiledDocumentModel doc) { + var view = doc.TextView; + if (view != null) + MainWindow.Instance.SelectNodes(view.GetState().DecompiledNodes); + } + } + } + void SetWindowBounds(Rect bounds) { this.Left = bounds.Left;