mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fixed single-item replace
This commit is contained in:
parent
a64997e395
commit
701e43bf1f
2 changed files with 28 additions and 16 deletions
|
@ -178,14 +178,21 @@ namespace IDE.ui
|
||||||
if (all)
|
if (all)
|
||||||
{
|
{
|
||||||
mEditWidget.SetFocus();
|
mEditWidget.SetFocus();
|
||||||
replaceCount = Replace();
|
replaceCount = Replace(true);
|
||||||
if (replaceCount > 0)
|
if (replaceCount > 0)
|
||||||
IDEApp.sApp.MessageDialog("Replace Results", StackStringFormat!("{0} instance(s) replaced.", replaceCount));
|
IDEApp.sApp.MessageDialog("Replace Results", StackStringFormat!("{0} instance(s) replaced.", replaceCount));
|
||||||
|
|
||||||
|
if (replaceCount != -1)
|
||||||
|
{
|
||||||
|
if (replaceCount == 0)
|
||||||
|
IDEApp.sApp.Fail("The search text wasn't found.");
|
||||||
|
mWidgetWindow.mIsKeyDownHandled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//replaceCount = Replace((byte)SourceElementFlags.Find_CurrentSelection);
|
//replaceCount = Replace((byte)SourceElementFlags.Find_CurrentSelection);
|
||||||
var content = mEditWidget.Content;
|
/*var content = mEditWidget.Content;
|
||||||
String replaceText = scope String();
|
String replaceText = scope String();
|
||||||
mReplaceEditWidget.GetText(replaceText);
|
mReplaceEditWidget.GetText(replaceText);
|
||||||
bool hasMatch = false;
|
bool hasMatch = false;
|
||||||
|
@ -203,15 +210,9 @@ namespace IDE.ui
|
||||||
{
|
{
|
||||||
content.InsertAtCursor(replaceText);
|
content.InsertAtCursor(replaceText);
|
||||||
mCurFindIdx = (int32)content.CursorTextPos - 1;
|
mCurFindIdx = (int32)content.CursorTextPos - 1;
|
||||||
}
|
}*/
|
||||||
FindNext(1, false);
|
Replace(false);
|
||||||
}
|
FindNext(1, true);
|
||||||
|
|
||||||
if (replaceCount != -1)
|
|
||||||
{
|
|
||||||
if (replaceCount == 0)
|
|
||||||
IDEApp.sApp.Fail("The search text wasn't found.");
|
|
||||||
mWidgetWindow.mIsKeyDownHandled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +546,7 @@ namespace IDE.ui
|
||||||
|
|
||||||
static int32 sReentryCount;
|
static int32 sReentryCount;
|
||||||
|
|
||||||
public int32 Replace()
|
public int32 Replace(bool replaceAll)
|
||||||
{
|
{
|
||||||
scope AutoBeefPerf("QuickFind.Replace");
|
scope AutoBeefPerf("QuickFind.Replace");
|
||||||
|
|
||||||
|
@ -561,6 +562,8 @@ namespace IDE.ui
|
||||||
|
|
||||||
//Profiler.StartSampling();
|
//Profiler.StartSampling();
|
||||||
|
|
||||||
|
SourceElementFlags findFlags = replaceAll ? .Find_Matches : .Find_CurrentSelection;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int32 selEnd = -1;
|
int32 selEnd = -1;
|
||||||
|
@ -568,7 +571,7 @@ namespace IDE.ui
|
||||||
var text = mEditWidget.Content.mData.mText;
|
var text = mEditWidget.Content.mData.mText;
|
||||||
for (int32 i = searchStart; i < mEditWidget.Content.mData.mTextLength; i++)
|
for (int32 i = searchStart; i < mEditWidget.Content.mData.mTextLength; i++)
|
||||||
{
|
{
|
||||||
if ((text[i].mDisplayFlags & (uint8)SourceElementFlags.Find_Matches) != 0)
|
if ((text[i].mDisplayFlags & (uint8)findFlags) != 0)
|
||||||
{
|
{
|
||||||
if (selStart == -1)
|
if (selStart == -1)
|
||||||
selStart = i;
|
selStart = i;
|
||||||
|
@ -600,8 +603,12 @@ namespace IDE.ui
|
||||||
insertFlags |= .IsGroupStart;
|
insertFlags |= .IsGroupStart;
|
||||||
ewc.InsertAtCursor(replaceText, insertFlags);
|
ewc.InsertAtCursor(replaceText, insertFlags);
|
||||||
|
|
||||||
|
/*if (selStart <= mCurFindIdx)
|
||||||
|
mCurFindIdx += (int32)(replaceText.Length - findText.Length);*/
|
||||||
|
|
||||||
searchStart = selStart + (int32)replaceText.Length;
|
searchStart = selStart + (int32)replaceText.Length;
|
||||||
searchCount++;
|
searchCount++;
|
||||||
|
DataUpdated();
|
||||||
|
|
||||||
/*if (flags == (byte)SourceElementFlags.Find_CurrentSelection)
|
/*if (flags == (byte)SourceElementFlags.Find_CurrentSelection)
|
||||||
{
|
{
|
||||||
|
@ -620,13 +627,18 @@ namespace IDE.ui
|
||||||
return searchCount;
|
return searchCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataUpdated()
|
||||||
|
{
|
||||||
|
mLastTextVersion = mEditWidget.Content.mData.mCurTextVersionId;
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateData()
|
public void UpdateData()
|
||||||
{
|
{
|
||||||
if (mLastTextVersion != mEditWidget.Content.mData.mCurTextVersionId)
|
if (mLastTextVersion != mEditWidget.Content.mData.mCurTextVersionId)
|
||||||
{
|
{
|
||||||
if (mIsShowingMatches)
|
if (mIsShowingMatches)
|
||||||
FindAll();
|
FindAll();
|
||||||
mLastTextVersion = mEditWidget.Content.mData.mCurTextVersionId;
|
DataUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateCursorPos();
|
UpdateCursorPos();
|
||||||
|
|
|
@ -3317,7 +3317,7 @@ void BfModule::ResolveConstField(BfTypeInstance* typeInstance, BfFieldInstance*
|
||||||
fieldType = fieldInstance->GetResolvedType();
|
fieldType = fieldInstance->GetResolvedType();
|
||||||
if ((fieldType == NULL) || (fieldType->IsVar()))
|
if ((fieldType == NULL) || (fieldType->IsVar()))
|
||||||
{
|
{
|
||||||
AssertZeberrorState();
|
AssertErrorState();
|
||||||
// Default const type is 'int'
|
// Default const type is 'int'
|
||||||
BfTypedValue initValue = GetDefaultTypedValue(GetPrimitiveType(BfTypeCode_IntPtr));
|
BfTypedValue initValue = GetDefaultTypedValue(GetPrimitiveType(BfTypeCode_IntPtr));
|
||||||
if (fieldInstance != NULL)
|
if (fieldInstance != NULL)
|
||||||
|
@ -3363,7 +3363,7 @@ BfType* BfModule::ResolveVarFieldType(BfTypeInstance* typeInstance, BfFieldInsta
|
||||||
|
|
||||||
if ((!field->mIsStatic) && (typeDef->mIsStatic))
|
if ((!field->mIsStatic) && (typeDef->mIsStatic))
|
||||||
{
|
{
|
||||||
AssertZeberrorState();
|
AssertErrorState();
|
||||||
return GetPrimitiveType(BfTypeCode_Var);
|
return GetPrimitiveType(BfTypeCode_Var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue