Author: fejj
Date: 2007-04-04 14:25:05 -0400 (Wed, 04 Apr 2007)
New Revision: 75401

Modified:
   trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/NavigationService.cs
Log:
2007-04-04  Jeffrey Stedfast  <[EMAIL PROTECTED]>

        * MonoDevelop.Ide.Gui/NavigationService.cs: Defer logging until the
        timeout has expired unless there has been a file change.



Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog        2007-04-04 
18:14:40 UTC (rev 75400)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog        2007-04-04 
18:25:05 UTC (rev 75401)
@@ -1,3 +1,8 @@
+2007-04-04  Jeffrey Stedfast  <[EMAIL PROTECTED]>
+
+       * MonoDevelop.Ide.Gui/NavigationService.cs: Defer logging until the
+       timeout has expired unless there has been a file change.
+
 2007-04-03  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
        * MonoDevelop.Ide.Gui/NavigationService.cs: Only log new points if the

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/NavigationService.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/NavigationService.cs
 2007-04-04 18:14:40 UTC (rev 75400)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/NavigationService.cs
 2007-04-04 18:25:05 UTC (rev 75401)
@@ -43,9 +43,9 @@
 #region Private members
                static LinkedList<INavigationPoint> history = new 
LinkedList<INavigationPoint> ();
                static LinkedListNode<INavigationPoint> currentNode; // 
autoinitialized to null (FxCop)
-               static LinkedListNode<INavigationPoint> lastLogged;
+               static INavigationPoint navPoint;
                static bool loggingSuspended; // autoinitialized to false 
(FxCop)
-               static int stamp;
+               static uint timeout;
 #endregion
                
                // TODO: FxCop says "find another way to do this" 
(ReviewVisibleEventHandlers)
@@ -55,6 +55,8 @@
                        
                        IdeApp.ProjectOperations.FileRenamedInProject += 
FileRenamed;
                        IdeApp.ProjectOperations.CombineClosed += 
SolutionClosed;
+                       
+                       timeout = GLib.Timeout.Add (1000, LogNavPoint);
                }
                
 #region Public Properties
@@ -119,7 +121,7 @@
                        
                        LogInternal (pointToLog);
                }
-
+               
                // refactoring this out of Log() allows the NavigationService
                // to call this and ensure it will work regardless of the
                // requested state of loggingSuspended
@@ -128,30 +130,34 @@
                        if (p == null || p.FileName == null || p.FileName == 
String.Empty)
                                return;
                        
-                       INavigationPoint o = lastLogged != null ? 
lastLogged.Value : null;
-                       int now = Environment.TickCount;
+                       if (navPoint != null && navPoint.FileName != 
p.FileName) {
+                               // always log last navpoint before switching 
files
+                               LogNavPoint ();
+                       }
                        
+                       // defer logging
+                       navPoint = p;
+               }
+               
+               static bool LogNavPoint ()
+               {
+                       if (navPoint == null || loggingSuspended)
+                               return true;
+                       
                        if (currentNode == null) {
-                               currentNode = history.AddFirst (p);
-                               lastLogged = currentNode;
-                               stamp = now;
-                       } else if (p.Equals (currentNode.Value)) {
+                               currentNode = history.AddFirst (navPoint);
+                       } else if (navPoint.Equals (currentNode.Value)) {
                                // replace it
-                               currentNode.Value = p;
-                               lastLogged = currentNode;
-                               stamp = now;
-                       } else if ((now - stamp) > 1000 || o.FileName != 
p.FileName) {
-                               // enough time elapsed to log a new point or 
the file changed
-                               currentNode = history.AddAfter (currentNode, p);
-                               lastLogged = currentNode;
-                               stamp = now;
+                               currentNode.Value = navPoint;
                        } else {
-                               // not enough time has elapsed, overwrite last 
logged navpoint
-                               //lastLogged.Value = p;
-                               //stamp = now;
+                               currentNode = history.AddAfter (currentNode, 
navPoint);
                        }
                        
+                       navPoint = null;
+                       
                        OnHistoryChanged ();
+                       
+                       return true;
                }
                
                // untested
@@ -186,7 +192,6 @@
                        INavigationPoint currentPosition = CurrentPosition;
                        
                        history.Clear ();
-                       lastLogged = null;
                        currentNode = null;
                        
                        if (!clearCurrentPosition)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to