Skip to content

Commit

Permalink
fix KeyHandlerEditSession::Commit bug from 85b48f9
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhngtu committed May 30, 2021
1 parent c0722d7 commit 0aedc66
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions VietTypeATL/KeyHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,18 @@ HRESULT KeyHandlerEditSession::ComposeKey(_In_ TfEditCookie ec) {
}

HRESULT KeyHandlerEditSession::Commit(_In_ TfEditCookie ec) {
HRESULT hr;
HRESULT hr = S_OK;

if (_compositionManager->IsComposing()) {
#ifndef NDEBUG
auto txstate = _controller->GetEngine().Commit();
assert(txstate == Telex::TelexStates::Committed || txstate == Telex::TelexStates::CommittedInvalid);
#endif
auto str = _controller->GetEngine().Retrieve();
hr = _compositionManager->SetCompositionText(ec, &str[0], static_cast<LONG>(str.length()));
DBG_HRESULT_CHECK(hr, L"%s", L"_compositionManager->EnsureCompositionText failed");
if (txstate == Telex::TelexStates::Committed || txstate == Telex::TelexStates::CommittedInvalid) {
auto str = _controller->GetEngine().Retrieve();
hr = _compositionManager->SetCompositionText(ec, &str[0], static_cast<LONG>(str.length()));
DBG_HRESULT_CHECK(hr, L"%s", L"_compositionManager->EnsureCompositionText failed");
} else {
assert(txstate == Telex::TelexStates::Committed || txstate == Telex::TelexStates::CommittedInvalid);
hr = E_FAIL;
}
}

_controller->GetEngine().Reset();
Expand Down

0 comments on commit 0aedc66

Please sign in to comment.