Skip to content

Commit

Permalink
disable make phrases(search by wildchar, e.g. *), and FIX empty candi…
Browse files Browse the repository at this point in the history
…date list issue that would always cause crash in the past version!
  • Loading branch information
fanlumaster committed Jan 21, 2025
1 parent 0309289 commit 5c17898
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ CompileFlags:
Add: [
"-std=c++17", # needed when using MSVC
"-IC:\\Users\\SonnyCalcr\\EDisk\\CppCodes\\IMECodes\\DeerWritingBrush",
-DUNICODE,
-D_UNICODE,
-Wno-microsoft-goto,
-Wno-unused-value,
-Wno-nonportable-include-path,
-Wno-microsoft-extra-qualification
-Wno-microsoft-extra-qualification,
-Wno-invalid-token-paste
] # ignore some specific warnings
Diagnostics:
UnusedIncludes: None
3 changes: 2 additions & 1 deletion CompositionProcessorEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class CCompositionProcessorEngine
}
BOOL IsMakePhraseFromText()
{
return _hasMakePhraseFromText;
// return _hasMakePhraseFromText;
return 0;
}
BOOL IsKeystrokeSort()
{
Expand Down
1 change: 1 addition & 0 deletions KeyHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ HRESULT CSampleIME::_HandleCompositionInputWorker(_In_ CCompositionProcessorEngi
//
CSampleImeArray<CCandidateListItem> candidateList;

// 重点:生成候选列表
pCompositionProcessorEngine->GetCandidateList(&candidateList, TRUE, FALSE);

if ((candidateList.Count()))
Expand Down
4 changes: 2 additions & 2 deletions SampleIMEBaseStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ struct CCandidateListItem

CCandidateListItem &CCandidateListItem::operator=(const CCandidateListItem &rhs)
{
_ItemString = rhs._ItemString;
_FindKeyCode = rhs._FindKeyCode;
_ItemString = rhs._ItemString; // e.g. 你好
_FindKeyCode = rhs._FindKeyCode; // e.g. nihao
return *this;
}
};
Expand Down
33 changes: 33 additions & 0 deletions TableDictionaryEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ VOID CTableDictionaryEngine::CollectWord(_In_ CStringRange *pKeyCode,
delete pdret;
pdret = nullptr;
}

if (!pItemList->Count())
{
CCandidateListItem *pLI = nullptr;
pLI = pItemList->Append();
// 使用用户输入的关键字作为默认值
const WCHAR *userInput = pKeyCode->Get(); // 获取用户输入的关键字
DWORD_PTR userInputLength = pKeyCode->GetLength(); // 获取用户输入的长度
pLI->_ItemString.Set(userInput, userInputLength); // 设置用户输入为默认值
pLI->_FindKeyCode.Set(userInput, userInputLength);
}
}

//+---------------------------------------------------------------------------
Expand Down Expand Up @@ -90,6 +101,17 @@ VOID CTableDictionaryEngine::CollectWordForWildcard(_In_ CStringRange *pKeyCode,
delete pdret;
pdret = nullptr;
}

if (!pItemList->Count())
{
CCandidateListItem *pLI = nullptr;
pLI = pItemList->Append();
// 使用用户输入的关键字作为默认值
const WCHAR *userInput = pKeyCode->Get(); // 获取用户输入的关键字
DWORD_PTR userInputLength = pKeyCode->GetLength(); // 获取用户输入的长度
pLI->_ItemString.Set(userInput, userInputLength); // 设置用户输入为默认值
pLI->_FindKeyCode.Set(userInput, userInputLength);
}
}

//+---------------------------------------------------------------------------
Expand Down Expand Up @@ -120,4 +142,15 @@ VOID CTableDictionaryEngine::CollectWordFromConvertedStringForWildcard(
delete pdret;
pdret = nullptr;
}

if (!pItemList->Count())
{
CCandidateListItem *pLI = nullptr;
pLI = pItemList->Append();
// 使用用户输入的关键字作为默认值
const WCHAR *userInput = pString->Get(); // 获取用户输入的关键字
DWORD_PTR userInputLength = pString->GetLength(); // 获取用户输入的长度
pLI->_ItemString.Set(userInput, userInputLength); // 设置用户输入为默认值
pLI->_FindKeyCode.Set(userInput, userInputLength);
}
}
2 changes: 2 additions & 0 deletions linstall.ps1
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# 在调试的时候,只需要注册 64 位
# sudo regsvr32 "./build64/DEBUG/DeerWritingBrush.dll"
sudo regsvr32 "./build64/DEBUG/DeerWritingBrush.dll"
sudo regsvr32 "./build32/DEBUG/DeerWritingBrush.dll"
1 change: 1 addition & 0 deletions luninstall.ps1
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
sudo regsvr32 /u "./build64/DEBUG/DeerWritingBrush.dll"
sudo regsvr32 /u "./build32/DEBUG/DeerWritingBrush.dll"

0 comments on commit 5c17898

Please sign in to comment.