Browse Source

Alter Navigation to take the time since the last navigation into account. If less than 0.5 seconds, do a replacement automatically.

pull/132/head
Alex Lyman 14 years ago
parent
commit
00828463a6
  1. 2
      ILSpy/MainWindow.xaml.cs
  2. 27
      ILSpy/NavigationHistory.cs

2
ILSpy/MainWindow.xaml.cs

@ -587,7 +587,7 @@ namespace ICSharpCode.ILSpy @@ -587,7 +587,7 @@ namespace ICSharpCode.ILSpy
var currentSelection = treeView.SelectedItems.OfType<SharpTreeNode>().ToList();
var state = decompilerTextView.GetState();
var combinedState = Tuple.Create(currentSelection, state);
history.Replace(combinedState);
history.Record(combinedState, replace: true, clearForward: false);
var newState = forward ? history.GoForward() : history.GoBack();
ignoreDecompilationRequests = true;

27
ILSpy/NavigationHistory.cs

@ -14,6 +14,9 @@ namespace ICSharpCode.ILSpy @@ -14,6 +14,9 @@ namespace ICSharpCode.ILSpy
internal sealed class NavigationHistory<T>
where T : class
{
private const double NavigationSecondsBeforeNewEntry = 0.5;
private DateTime lastNavigationTime = DateTime.MinValue;
T current;
List<T> back = new List<T>();
List<T> forward = new List<T>();
@ -54,18 +57,24 @@ namespace ICSharpCode.ILSpy @@ -54,18 +57,24 @@ namespace ICSharpCode.ILSpy
forward.Clear();
}
public void Replace(T node)
public void Record(T node, bool replace = false, bool clearForward = true)
{
current = node;
}
var navigationTime = DateTime.Now;
var period = navigationTime - lastNavigationTime;
public void Record(T node)
{
if (current != null)
back.Add(current);
if (period.TotalSeconds < NavigationSecondsBeforeNewEntry || replace) {
current = node;
} else {
if (current != null)
back.Add(current);
forward.Clear();
current = node;
current = node;
}
if (clearForward)
forward.Clear();
lastNavigationTime = navigationTime;
}
}
}

Loading…
Cancel
Save