aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32/ScintillaWin.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'win32/ScintillaWin.cxx')
-rw-r--r--win32/ScintillaWin.cxx18
1 files changed, 14 insertions, 4 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 806d915b7..c6733469c 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -277,6 +277,11 @@ public:
return attr;
}
+ LONG GetCompositionStringLength(DWORD dwIndex) const noexcept {
+ const LONG byteLen = ::ImmGetCompositionStringW(hIMC, dwIndex, nullptr, 0);
+ return byteLen / sizeof(wchar_t);
+ }
+
std::wstring GetCompositionString(DWORD dwIndex) {
const LONG byteLen = ::ImmGetCompositionStringW(hIMC, dwIndex, nullptr, 0);
std::wstring wcs(byteLen / 2, 0);
@@ -3184,9 +3189,14 @@ LRESULT ScintillaWin::ImeOnDocumentFeed(LPARAM lParam) const {
if (!imc.hIMC)
return 0;
- const size_t compStrLen = imc.GetCompositionString(GCS_COMPSTR).size();
- 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.
@@ -3194,7 +3204,7 @@ LRESULT ScintillaWin::ImeOnDocumentFeed(LPARAM lParam) const {
rc->dwVersion = 0; //constant
rc->dwStrLen = static_cast<DWORD>(rcFeed.length());
rc->dwStrOffset = sizeof(RECONVERTSTRING); //constant
- rc->dwCompStrLen = static_cast<DWORD>(compStrLen);
+ rc->dwCompStrLen = compStrLen;
rc->dwCompStrOffset = static_cast<DWORD>(compStrOffset) * sizeof(wchar_t);
rc->dwTargetStrLen = rc->dwCompStrLen;
rc->dwTargetStrOffset = rc->dwCompStrOffset;