Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Stedfast <jeff@xamarin.com>2012-01-05 02:06:30 +0400
committerJeffrey Stedfast <jeff@xamarin.com>2012-01-05 02:06:30 +0400
commit351ca25229ce770a1f8c75edbc556c11423378a1 (patch)
tree41d2bb97b5865f428d84b20a3c947bcd7e23746f
parent3a4ded849f65ac95f1beb3cf22e3656e67e97553 (diff)
[Ide] Slight optimizations to document loading on startup.
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs79
1 files changed, 35 insertions, 44 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
index 5c132516bc..9b635a01df 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
@@ -343,39 +343,41 @@ namespace MonoDevelop.Ide.Gui
{
if (string.IsNullOrEmpty (fileName))
return null;
+
using (Counters.OpenDocumentTimer.BeginTiming ("Opening file " + fileName)) {
NavigationHistoryService.LogActiveDocument ();
- Counters.OpenDocumentTimer.Trace ("Look for open document");
-
- foreach (Document doc in Documents) {
- IBaseViewContent vcFound = null;
- int vcIndex = 0;
-
- //search all ViewContents to see if they can "re-use" this filename
- if (doc.Window.ViewContent.CanReuseView (fileName))
- vcFound = doc.Window.ViewContent;
-
-
- //old method as fallback
- if ((vcFound == null) && (doc.FileName == fileName))
- vcFound = doc.Window.ViewContent;
+ if (options.HasFlag (OpenDocumentOptions.TryToReuseViewer)) {
+ Counters.OpenDocumentTimer.Trace ("Look for open document");
- //if found, select window and jump to line
- if (vcFound != null) {
- IEditableTextBuffer ipos = vcFound.GetContent<IEditableTextBuffer> ();
- if (line >= 1 && ipos != null) {
- ipos.SetCaretTo (line, column >= 1 ? column : 1, options.HasFlag (OpenDocumentOptions.HighlightCaretLine), options.HasFlag (OpenDocumentOptions.CenterCaretLine));
- }
+ foreach (Document doc in Documents) {
+ IBaseViewContent vcFound = null;
+ int vcIndex = 0;
+
+ //search all ViewContents to see if they can "re-use" this filename
+ if (doc.Window.ViewContent.CanReuseView (fileName))
+ vcFound = doc.Window.ViewContent;
+
+ //old method as fallback
+ if ((vcFound == null) && (doc.FileName == fileName))
+ vcFound = doc.Window.ViewContent;
- if (options.HasFlag (OpenDocumentOptions.BringToFront)) {
- doc.Select ();
- doc.Window.SwitchView (vcIndex);
- doc.Window.SelectWindow ();
- NavigationHistoryService.LogActiveDocument ();
- Present ();
+ //if found, select window and jump to line
+ if (vcFound != null) {
+ IEditableTextBuffer ipos = vcFound.GetContent<IEditableTextBuffer> ();
+ if (line >= 1 && ipos != null) {
+ ipos.SetCaretTo (line, column >= 1 ? column : 1, options.HasFlag (OpenDocumentOptions.HighlightCaretLine), options.HasFlag (OpenDocumentOptions.CenterCaretLine));
+ }
+
+ if (options.HasFlag (OpenDocumentOptions.BringToFront)) {
+ doc.Select ();
+ doc.Window.SwitchView (vcIndex);
+ doc.Window.SelectWindow ();
+ NavigationHistoryService.LogActiveDocument ();
+ Present ();
+ }
+ return doc;
}
- return doc;
}
}
@@ -699,6 +701,7 @@ namespace MonoDevelop.Ide.Gui
monitor.ReportError (GettextCatalog.GetString ("{0} is a directory", fileName), null);
return;
}
+
// test, if file fileName exists
if (!origName.StartsWith("http://")) {
// test, if an untitled file should be opened
@@ -717,22 +720,6 @@ namespace MonoDevelop.Ide.Gui
}
}
- foreach (Document doc in Documents) {
- if (doc.FileName == fileName) {
- if (openFileInfo.Options.HasFlag (OpenDocumentOptions.BringToFront)) {
- doc.Select ();
- doc.RunWhenLoaded (delegate {
- IEditableTextBuffer ipos = doc.GetContent <IEditableTextBuffer> ();
- if (openFileInfo.Line > 0 && ipos != null) {
- ipos.SetCaretTo (openFileInfo.Line, Math.Max (1, openFileInfo.Column), openFileInfo.Options.HasFlag (OpenDocumentOptions.HighlightCaretLine));
- }
- });
- }
- openFileInfo.NewContent = doc.Window.ViewContent;
- return;
- }
- }
-
Counters.OpenDocumentTimer.Trace ("Looking for binding");
IDisplayBinding binding = null;
@@ -756,6 +743,7 @@ namespace MonoDevelop.Ide.Gui
viewBinding = binding as IViewDisplayBinding;
}
}
+
try {
if (binding != null) {
if (viewBinding != null) {
@@ -1075,6 +1063,7 @@ namespace MonoDevelop.Ide.Gui
fileInfo.ProgressMonitor.ReportError (GettextCatalog.GetString ("The file '{0}' could not be opened.", fileName), ex);
return;
}
+
// content got re-used
if (newContent.WorkbenchWindow != null) {
newContent.WorkbenchWindow.SelectWindow ();
@@ -1092,6 +1081,7 @@ namespace MonoDevelop.Ide.Gui
IEditableTextBuffer ipos = newContent.GetContent<IEditableTextBuffer> ();
if (fileInfo.Line > 0 && ipos != null)
JumpToLine ();
+
fileInfo.NewContent = newContent;
}
@@ -1113,7 +1103,8 @@ namespace MonoDevelop.Ide.Gui
HighlightCaretLine = 1 << 2,
OnlyInternalViewer = 1 << 3,
OnlyExternalViewer = 1 << 4,
+ TryToReuseViewer = 1 << 5,
- Default = BringToFront | CenterCaretLine | HighlightCaretLine
+ Default = BringToFront | CenterCaretLine | HighlightCaretLine | TryToReuseViewer
}
}