From 45d6a12d5d1b9c8559f82daaf83f7114fffa0d1d Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 31 Dec 2024 10:28:04 -0800 Subject: [PATCH] Added autocomplete "all" option for ctor passthroughs --- BeefySysLib/util/String.cpp | 4 ++-- IDEHelper/Compiler/BfAutoComplete.cpp | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/BeefySysLib/util/String.cpp b/BeefySysLib/util/String.cpp index b718bf16..7eee2859 100644 --- a/BeefySysLib/util/String.cpp +++ b/BeefySysLib/util/String.cpp @@ -654,7 +654,7 @@ void StringImpl::ReplaceLargerHelper(const StringView& find, const StringView& r intptr moveOffset = replace.mLength - find.mLength; - for (intptr startIdx = 0; startIdx < mLength - find.mLength; startIdx++) + for (intptr startIdx = 0; startIdx <= mLength - find.mLength; startIdx++) { if (EqualsHelper(GetPtr() + startIdx, find.mPtr, find.mLength)) { @@ -720,7 +720,7 @@ void StringImpl::Replace(const StringView& find, const StringView & replace) intptr inIdx = 0; intptr outIdx = 0; - while (inIdx < mLength - find.mLength) + while (inIdx <= mLength - find.mLength) { if (EqualsHelper(ptr + inIdx, findPtr, find.mLength)) { diff --git a/IDEHelper/Compiler/BfAutoComplete.cpp b/IDEHelper/Compiler/BfAutoComplete.cpp index 687d7921..3ade56ab 100644 --- a/IDEHelper/Compiler/BfAutoComplete.cpp +++ b/IDEHelper/Compiler/BfAutoComplete.cpp @@ -2760,7 +2760,7 @@ void BfAutoComplete::AddOverrides(const StringImpl& filter) BfTypeInstance* curType = mModule->mCurTypeInstance; while (curType != NULL) - { + { for (auto methodDef : curType->mTypeDef->mMethods) { if (methodDef->mShow >= checkShow) @@ -2812,8 +2812,8 @@ void BfAutoComplete::AddOverrides(const StringImpl& filter) StringT<512> insertString; GetMethodInfo(methodInst, &insertString, &insertString, true, false); if (insertString.IsEmpty()) - continue; - AddEntry(AutoCompleteEntry("override", insertString), filter); + continue; + AddEntry(AutoCompleteEntry("override", insertString), filter); } if (curType->IsStruct()) @@ -2833,6 +2833,8 @@ void BfAutoComplete::AddCtorPassthroughs() BfTypeInstance* curType = mModule->mCurTypeInstance; auto baseType = curType->mBaseType; + String totalInsertString; + Array declMethods; for (auto methodDef : curType->mTypeDef->mMethods) { @@ -2847,7 +2849,7 @@ void BfAutoComplete::AddCtorPassthroughs() continue; declMethods.Add(methodInst); } - + for (auto methodDef : baseType->mTypeDef->mMethods) { if (methodDef->mShow != BfShow_Show) @@ -2884,6 +2886,21 @@ void BfAutoComplete::AddCtorPassthroughs() if (insertString.IsEmpty()) continue; AddEntry(AutoCompleteEntry("this", insertString), ""); + + int tabPos = (int)insertString.IndexOf('\t'); + if (tabPos >= 0) + { + if (!totalInsertString.IsEmpty()) + totalInsertString += "\r\r"; + totalInsertString += insertString.Substring(tabPos + 1); + } + } + + if ((!totalInsertString.IsEmpty()) && (mEntriesSet.GetCount() >= 2)) + { + totalInsertString.Replace("\t", "\t\b"); + totalInsertString.Insert(0, "this - all\t"); + auto entry = AddEntry(AutoCompleteEntry("this", totalInsertString), ""); } }