diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-06-24 13:53:06 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-06-24 13:53:06 +0400 |
commit | 593abbfabed32fc324320e3ffedfff6cec2174a1 (patch) | |
tree | 189b2cc6c6fb6ec2af8979eb0be794abd6e75081 /main/src/addins/MonoDevelop.Refactoring | |
parent | e567486244c369bbf21a0bcf59434b2fac044e7a (diff) |
quick fix popup now has a little timer, prevents that too many
analysis calls are queued on caret moves.
Diffstat (limited to 'main/src/addins/MonoDevelop.Refactoring')
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.ContextAction/ContextActionEditorExtension.cs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.ContextAction/ContextActionEditorExtension.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.ContextAction/ContextActionEditorExtension.cs index a0d9ed8d56..2708c30212 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.ContextAction/ContextActionEditorExtension.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.ContextAction/ContextActionEditorExtension.cs @@ -40,6 +40,7 @@ namespace MonoDevelop.ContextAction public class ContextActionEditorExtension : TextEditorExtension { ContextActionWidget widget; + uint quickFixTimeout; public void RemoveWidget () { @@ -57,6 +58,7 @@ namespace MonoDevelop.ContextAction public override void Dispose () { + CancelQuickFixTimer (); document.DocumentParsed -= HandleDocumentDocumentParsed; RemoveWidget (); base.Dispose (); @@ -76,18 +78,30 @@ namespace MonoDevelop.ContextAction -2 + (int)document.Editor.Parent.LineToY (document.Editor.Caret.Line)); widget.Show (); } + + public void CancelQuickFixTimer () + { + if (quickFixTimeout != 0) { + GLib.Source.Remove (quickFixTimeout); + quickFixTimeout = 0; + } + } public override void CursorPositionChanged () { RemoveWidget (); - + CancelQuickFixTimer (); if (Document.ParsedDocument != null) { - AstLocation loc = new AstLocation (Document.Editor.Caret.Line, Document.Editor.Caret.Column); - RefactoringService.QueueQuickFixAnalysis (Document, loc, delegate(List<ContextAction> fixes) { - Application.Invoke (delegate { - RemoveWidget (); - CreateWidget (fixes, loc); + quickFixTimeout = GLib.Timeout.Add (100, delegate { + AstLocation loc = new AstLocation (Document.Editor.Caret.Line, Document.Editor.Caret.Column); + RefactoringService.QueueQuickFixAnalysis (Document, loc, delegate(List<ContextAction> fixes) { + Application.Invoke (delegate { + RemoveWidget (); + CreateWidget (fixes, loc); + }); }); + quickFixTimeout = 0; + return false; }); } base.CursorPositionChanged (); |