344
344
if (string.IsNullOrEmpty (fileName))
346
347
using (Counters.OpenDocumentTimer.BeginTiming ("Opening file " + fileName)) {
347
348
NavigationHistoryService.LogActiveDocument ();
349
Counters.OpenDocumentTimer.Trace ("Look for open document");
351
foreach (Document doc in Documents) {
352
IBaseViewContent vcFound = null;
355
//search all ViewContents to see if they can "re-use" this filename
356
if (doc.Window.ViewContent.CanReuseView (fileName))
357
vcFound = doc.Window.ViewContent;
360
//old method as fallback
361
if ((vcFound == null) && (doc.FileName == fileName))
362
vcFound = doc.Window.ViewContent;
364
//if found, select window and jump to line
365
if (vcFound != null) {
366
IEditableTextBuffer ipos = vcFound.GetContent<IEditableTextBuffer> ();
367
if (line >= 1 && ipos != null) {
368
ipos.SetCaretTo (line, column >= 1 ? column : 1, options.HasFlag (OpenDocumentOptions.HighlightCaretLine), options.HasFlag (OpenDocumentOptions.CenterCaretLine));
371
if (options.HasFlag (OpenDocumentOptions.BringToFront)) {
373
doc.Window.SwitchView (vcIndex);
374
doc.Window.SelectWindow ();
375
NavigationHistoryService.LogActiveDocument ();
350
if (options.HasFlag (OpenDocumentOptions.TryToReuseViewer)) {
351
Counters.OpenDocumentTimer.Trace ("Look for open document");
353
foreach (Document doc in Documents) {
354
IBaseViewContent vcFound = null;
357
//search all ViewContents to see if they can "re-use" this filename
358
if (doc.Window.ViewContent.CanReuseView (fileName))
359
vcFound = doc.Window.ViewContent;
361
//old method as fallback
362
if ((vcFound == null) && (doc.FileName == fileName))
363
vcFound = doc.Window.ViewContent;
365
//if found, select window and jump to line
366
if (vcFound != null) {
367
IEditableTextBuffer ipos = vcFound.GetContent<IEditableTextBuffer> ();
368
if (line >= 1 && ipos != null) {
369
ipos.SetCaretTo (line, column >= 1 ? column : 1, options.HasFlag (OpenDocumentOptions.HighlightCaretLine), options.HasFlag (OpenDocumentOptions.CenterCaretLine));
372
if (options.HasFlag (OpenDocumentOptions.BringToFront)) {
374
doc.Window.SwitchView (vcIndex);
375
doc.Window.SelectWindow ();
376
NavigationHistoryService.LogActiveDocument ();
699
701
monitor.ReportError (GettextCatalog.GetString ("{0} is a directory", fileName), null);
702
705
// test, if file fileName exists
703
706
if (!origName.StartsWith("http://")) {
704
707
// test, if an untitled file should be opened
720
foreach (Document doc in Documents) {
721
if (doc.FileName == fileName) {
722
if (openFileInfo.Options.HasFlag (OpenDocumentOptions.BringToFront)) {
724
doc.RunWhenLoaded (delegate {
725
IEditableTextBuffer ipos = doc.GetContent <IEditableTextBuffer> ();
726
if (openFileInfo.Line > 0 && ipos != null) {
727
ipos.SetCaretTo (openFileInfo.Line, Math.Max (1, openFileInfo.Column), openFileInfo.Options.HasFlag (OpenDocumentOptions.HighlightCaretLine));
731
openFileInfo.NewContent = doc.Window.ViewContent;
736
723
Counters.OpenDocumentTimer.Trace ("Looking for binding");
738
725
IDisplayBinding binding = null;
1113
1103
HighlightCaretLine = 1 << 2,
1114
1104
OnlyInternalViewer = 1 << 3,
1115
1105
OnlyExternalViewer = 1 << 4,
1106
TryToReuseViewer = 1 << 5,
1117
Default = BringToFront | CenterCaretLine | HighlightCaretLine
1108
Default = BringToFront | CenterCaretLine | HighlightCaretLine | TryToReuseViewer,
1109
Debugger = BringToFront | CenterCaretLine | TryToReuseViewer