Browse Source

Fixed SD2-998 - Find or replace all in all open documents hangs SharpDevelop if two or more text files are open. The new docking library does not set the ActiveWorkbenchWindow until certain windows messages have been processed which caused the AllOpenDocumentIterator class to not be able to change the active window and kept the search stuck in an infinite loop. The AllOpenDocumentIterator class has been modified to use an index to determine the currently searched document window rather than relying on the ActiveWorkbenchWindow.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1941 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 20 years ago
parent
commit
35546c0348
  1. 70
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/DocumentIterator/AllOpenDocumentIterator.cs

70
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/DocumentIterator/AllOpenDocumentIterator.cs

@ -18,7 +18,8 @@ namespace SearchAndReplace @@ -18,7 +18,8 @@ namespace SearchAndReplace
public class AllOpenDocumentIterator : IDocumentIterator
{
int startIndex = -1;
bool resetted = true;
int curIndex = -1;
bool resetted = true;
public AllOpenDocumentIterator()
{
@ -27,45 +28,60 @@ namespace SearchAndReplace @@ -27,45 +28,60 @@ namespace SearchAndReplace
public string CurrentFileName {
get {
if (!SearchReplaceUtilities.IsTextAreaSelected) {
return null;
IViewContent viewContent = GetCurrentTextEditorViewContent();
if (viewContent != null) {
if (viewContent.FileName == null) {
return viewContent.UntitledName;
}
return viewContent.FileName;
}
return null;
}
}
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.FileName == null) {
return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.UntitledName;
IViewContent GetCurrentTextEditorViewContent()
{
GetCurIndex();
if (curIndex >= 0) {
IViewContent viewContent = WorkbenchSingleton.Workbench.ViewContentCollection[curIndex];
if (viewContent is ITextEditorControlProvider) {
return viewContent;
}
return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.FileName;
}
return null;
}
public ProvidedDocumentInformation Current {
get {
if (!SearchReplaceUtilities.IsTextAreaSelected) {
return null;
IViewContent viewContent = GetCurrentTextEditorViewContent();
if (viewContent != null) {
TextEditorControl textEditor = (((ITextEditorControlProvider)viewContent).TextEditorControl);
IDocument document = textEditor.Document;
return new ProvidedDocumentInformation(document,
CurrentFileName,
textEditor.ActiveTextAreaControl);
}
TextEditorControl textEditor = (((ITextEditorControlProvider)WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent).TextEditorControl);
IDocument document = textEditor.Document;
return new ProvidedDocumentInformation(document,
CurrentFileName,
textEditor.ActiveTextAreaControl);
return null;
}
}
int GetCurIndex()
void GetCurIndex()
{
for (int i = 0; i < WorkbenchSingleton.Workbench.ViewContentCollection.Count; ++i) {
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent == WorkbenchSingleton.Workbench.ViewContentCollection[i]) {
return i;
int viewCount = WorkbenchSingleton.Workbench.ViewContentCollection.Count;
if (curIndex == -1 || curIndex >= viewCount) {
for (int i = 0; i < viewCount; ++i) {
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent == WorkbenchSingleton.Workbench.ViewContentCollection[i]) {
curIndex = i;
return;
}
}
curIndex = -1;
}
return -1;
}
public bool MoveForward()
{
int curIndex = GetCurIndex();
GetCurIndex();
if (curIndex < 0) {
return false;
}
@ -75,17 +91,16 @@ namespace SearchAndReplace @@ -75,17 +91,16 @@ namespace SearchAndReplace
return true;
}
int nextIndex = (curIndex + 1) % WorkbenchSingleton.Workbench.ViewContentCollection.Count;
if (nextIndex == startIndex) {
curIndex = (curIndex + 1) % WorkbenchSingleton.Workbench.ViewContentCollection.Count;
if (curIndex == startIndex) {
return false;
}
WorkbenchSingleton.Workbench.ViewContentCollection[nextIndex].WorkbenchWindow.SelectWindow();
return true;
}
public bool MoveBackward()
{
int curIndex = GetCurIndex();
GetCurIndex();
if (curIndex < 0) {
return false;
}
@ -100,7 +115,6 @@ namespace SearchAndReplace @@ -100,7 +115,6 @@ namespace SearchAndReplace
if (curIndex > 0) {
--curIndex;
WorkbenchSingleton.Workbench.ViewContentCollection[curIndex].WorkbenchWindow.SelectWindow();
return true;
}
return false;
@ -108,7 +122,9 @@ namespace SearchAndReplace @@ -108,7 +122,9 @@ namespace SearchAndReplace
public void Reset()
{
startIndex = GetCurIndex();
curIndex = -1;
GetCurIndex();
startIndex = curIndex;
resetted = true;
}
}

Loading…
Cancel
Save