Skip to content

Commit

Permalink
fix(tsf): use ITfContext::GetSelection to get cursor position
Browse files Browse the repository at this point in the history
avoid any insertion which could active document focus
fix rime#193, rime#194
  • Loading branch information
nameoverflow committed Apr 13, 2018
1 parent 2f3b283 commit 5664481
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions WeaselTSF/Composition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ STDAPI CGetTextExtentEditSession::DoEditSession(TfEditCookie ec)
ITfRange *pRangeComposition = NULL;
RECT rc;
BOOL fClipped;
if ((_pContext->QueryInterface(IID_ITfInsertAtSelection, (LPVOID *) &pInsertAtSelection)) != S_OK)
TF_SELECTION selection;
ULONG nSelection;
if (FAILED(_pContext->QueryInterface(IID_ITfInsertAtSelection, (LPVOID *) &pInsertAtSelection)))
goto Exit;
if ((pInsertAtSelection->InsertTextAtSelection(ec, TF_IAS_QUERYONLY, NULL, 0, &pRangeComposition)) != S_OK)
if (FAILED(_pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &selection, &nSelection)))
goto Exit;

if ((_pContextView->GetTextExt(ec, pRangeComposition, &rc, &fClipped)) == S_OK && (rc.left != 0 || rc.top != 0))
if ((_pContextView->GetTextExt(ec, selection.range, &rc, &fClipped)) == S_OK && (rc.left != 0 || rc.top != 0))
_pTextService->_SetCompositionPosition(rc);

Exit:
Expand Down

0 comments on commit 5664481

Please sign in to comment.