44
44
using ICSharpCode . Decompiler . Documentation ;
45
45
using ICSharpCode . Decompiler . TypeSystem . Implementation ;
46
46
using System . Reflection . Metadata ;
47
+ using System . Text ;
48
+ using System . Windows . Navigation ;
47
49
48
50
using ICSharpCode . ILSpy . AppEnv ;
49
51
using ICSharpCode . ILSpy . Search ;
50
52
using ICSharpCode . Decompiler ;
51
- using System . Text ;
52
53
53
54
using TomsToolbox . Essentials ;
54
55
using TomsToolbox . Wpf ;
55
- using System . Windows . Navigation ;
56
56
57
57
namespace ICSharpCode . ILSpy . AssemblyTree
58
58
{
@@ -78,7 +78,7 @@ public AssemblyTreeModel()
78
78
MessageBus < NavigateToReferenceEventArgs > . Subscribers += JumpToReference ;
79
79
MessageBus < SettingsChangedEventArgs > . Subscribers += ( sender , e ) => Settings_PropertyChanged ( sender , e ) ;
80
80
81
- var selectionChangeThrottle = new DispatcherThrottle ( DispatcherPriority . Background , TreeView_SelectionChanged ) ;
81
+ var selectionChangeThrottle = new DispatcherThrottle ( DispatcherPriority . Input , TreeView_SelectionChanged ) ;
82
82
SelectedItems . CollectionChanged += ( _ , _ ) => selectionChangeThrottle . Tick ( ) ;
83
83
}
84
84
@@ -128,6 +128,14 @@ public SharpTreeNode SelectedItem {
128
128
129
129
public ObservableCollection < SharpTreeNode > SelectedItems { get ; } = [ ] ;
130
130
131
+ private bool isInternalSelectionChanging ;
132
+
133
+ private void ChangingSelection ( )
134
+ {
135
+ isInternalSelectionChanging = true ;
136
+ this . Dispatcher . BeginInvoke ( DispatcherPriority . Background , ( ) => isInternalSelectionChanging = false ) ;
137
+ }
138
+
131
139
public string [ ] SelectedPath => GetPathForNode ( SelectedItem ) ;
132
140
133
141
readonly List < LoadedAssembly > commandLineLoadedAssemblies = [ ] ;
@@ -496,6 +504,7 @@ public void SelectNode(SharpTreeNode node, bool inNewTabPage = false)
496
504
}
497
505
else
498
506
{
507
+ ChangingSelection ( ) ;
499
508
activeView ? . ScrollIntoView ( node ) ;
500
509
SelectedItem = node ;
501
510
}
@@ -519,6 +528,7 @@ internal void SelectNodes(IEnumerable<SharpTreeNode> nodes)
519
528
return ;
520
529
}
521
530
531
+ ChangingSelection ( ) ;
522
532
SelectedItems . Clear ( ) ;
523
533
SelectedItems . AddRange ( nodesList ) ;
524
534
}
@@ -691,20 +701,17 @@ void TreeView_SelectionChanged()
691
701
{
692
702
if ( SelectedItems . Count > 0 )
693
703
{
694
- bool isRightButtonPressed = Mouse . RightButton == MouseButtonState . Pressed ;
695
- bool isLeftButtonPressed = Mouse . LeftButton == MouseButtonState . Pressed ;
696
-
697
- if ( isLeftButtonPressed || isRightButtonPressed )
704
+ if ( ! isInternalSelectionChanging )
698
705
{
699
- // record history only if change is initiated by user
706
+ // record history only if change is initiated by user input
700
707
var activeTabPage = DockWorkspace . Instance . ActiveTabPage ;
701
708
var currentState = activeTabPage . GetState ( ) ;
702
709
if ( currentState != null )
703
710
history . UpdateCurrent ( new NavigationState ( activeTabPage , currentState ) ) ;
704
711
history . Record ( new NavigationState ( activeTabPage , SelectedItems ) ) ;
705
712
}
706
713
707
- var delayDecompilationRequestDueToContextMenu = isRightButtonPressed ;
714
+ var delayDecompilationRequestDueToContextMenu = Mouse . RightButton == MouseButtonState . Pressed ;
708
715
709
716
if ( ! delayDecompilationRequestDueToContextMenu )
710
717
{
@@ -855,6 +862,7 @@ public void Refresh()
855
862
856
863
private void UnselectAll ( )
857
864
{
865
+ ChangingSelection ( ) ;
858
866
SelectedItems . Clear ( ) ;
859
867
}
860
868
0 commit comments