Skip to content

Commit

Permalink
Fix crash due to incorrect IME document feed, issue #775.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Mar 21, 2024
1 parent 65ccf25 commit 339e3fa
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scintilla/win32/ScintillaWin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3438,9 +3438,14 @@ LRESULT ScintillaWin::ImeOnDocumentFeed(LPARAM lParam) const {
return 0;
}

const DWORD compStrLen = imc.GetCompositionStringLength(GCS_COMPSTR);
const int imeCaretPos = imc.GetImeCaretPos();
const Sci::Position compStart = pdoc->GetRelativePositionUTF16(curPos, -imeCaretPos);
DWORD compStrLen = 0;
Sci::Position compStart = curPos;
if (pdoc->TentativeActive()) {
// rcFeed contains current composition string
compStrLen = imc.GetCompositionStringLength(GCS_COMPSTR);
const int imeCaretPos = imc.GetImeCaretPos();
compStart = pdoc->GetRelativePositionUTF16(curPos, -imeCaretPos);
}
const Sci::Position compStrOffset = pdoc->CountUTF16(lineStart, compStart);

// Fill in reconvert structure.
Expand Down

0 comments on commit 339e3fa

Please sign in to comment.