aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2024-03-22 15:28:29 +1100
committerZufu Liu <unknown>2024-03-22 15:28:29 +1100
commitd853508df8c3d391ff841aa9ad65670b4e163422 (patch)
tree65065bc8614bc984fcbe05b4c8151e7f8667287f
parentaa0beb40d25211189c30d69be4c07d3c25dfe6e2 (diff)
downloadscintilla-mirror-d853508df8c3d391ff841aa9ad65670b4e163422.tar.gz
Bug [#2433]. Fix IME crash in windowed mode.
-rw-r--r--doc/ScintillaHistory.html6
-rw-r--r--win32/ScintillaWin.cxx18
2 files changed, 19 insertions, 5 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 9ec26d44c..331a76420 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -584,7 +584,7 @@
</table>
<h2>Releases</h2>
<h3>
- <a href="https://www.scintilla.org/scintilla544.zip">Release 5.4.4</a>
+ <a href="https://www.scintilla.org/scintilla550.zip">Release 5.5.0</a>
</h3>
<ul>
<li>
@@ -596,6 +596,10 @@
When not set these default to SC_ELEMENT_SELECTION_INACTIVE_TEXT and SC_ELEMENT_SELECTION_INACTIVE_BACK.
<a href="https://sourceforge.net/p/scintilla/bugs/2417/">Bug #2417</a>.
</li>
+ <li>
+ Fix Win32 IME crash in windowed mode.
+ <a href="https://sourceforge.net/p/scintilla/bugs/2433/">Bug #2433</a>.
+ </li>
</ul>
<h3>
<a href="https://www.scintilla.org/scintilla543.zip">Release 5.4.3</a>
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;