Skip to content

Commit

Permalink
Fix Japanese IME caret not moved after pressing Space (revert 4378281).
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Jul 13, 2019
1 parent 1c85f52 commit 5a3beaf
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions scintilla/win32/ScintillaWin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ ScintillaWin::ScintillaWin(HWND hwnd) {
sysCaretBitmap = nullptr;
sysCaretWidth = 0;
sysCaretHeight = 0;
inputLang = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
inputLang = LANG_USER_DEFAULT;

styleIdleInQueue = false;

Expand Down Expand Up @@ -1300,11 +1300,19 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
i += ucWidth;
}

if (lParam & CS_NOMOVECARET) {
// Retrieve the selection range information. If CS_NOMOVECARET is specified,
// that means the cursor should not be moved, then we just place the caret at
// the beginning of the composition string. Otherwise we should honour the
// GCS_CURSORPOS value if it's available.
Sci::Position imeEndToImeCaretU16 = -static_cast<Sci::Position>(wcs.size());
if (!(lParam & CS_NOMOVECARET) && (lParam & GCS_CURSORPOS)) {
imeEndToImeCaretU16 += imc.GetImeCaretPos();
}
if (imeEndToImeCaretU16) {
// Move back IME caret from current last position to imeCaretPos.
const LONG imeEndToImeCaretU16 = imc.GetImeCaretPos() - static_cast<LONG>(wcs.size());
const Sci::Position imeCaretPosDoc = pdoc->GetRelativePositionUTF16(CurrentPosition(), imeEndToImeCaretU16);
MoveImeCarets(-CurrentPosition() + imeCaretPosDoc);
const Sci::Position currentPos = CurrentPosition();
const Sci::Position imeCaretPosDoc = pdoc->GetRelativePositionUTF16(currentPos, imeEndToImeCaretU16);
MoveImeCarets(-currentPos + imeCaretPosDoc);
}

view.imeCaretBlockOverride = KoreanIME();
Expand Down

0 comments on commit 5a3beaf

Please sign in to comment.