[LyX/master] Fix condition for IM composition mode
Koji Yokota
yokota at lyx.org
Fri Jun 12 08:41:47 UTC 2026
commit 1a01d6c04b2d0458ed0459b09bbf3f21fe06aa07
Author: Koji Yokota <yokota at lyx.org>
Date: Fri Jun 12 16:01:52 2026 +0900
Fix condition for IM composition mode
---
src/frontends/qt/GuiInputMethod.cpp | 25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/src/frontends/qt/GuiInputMethod.cpp b/src/frontends/qt/GuiInputMethod.cpp
index e7072024a3..61c42c688f 100644
--- a/src/frontends/qt/GuiInputMethod.cpp
+++ b/src/frontends/qt/GuiInputMethod.cpp
@@ -483,32 +483,17 @@ void GuiInputMethod::setPreeditStyle(
}
#endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- // composing mode: it has no focused segments
- // composing mode in Qt version 6 or later gives focus_style->length == 0 and
- // focus_style->start > d->preedit_str_.length() on MacOS (undocumented)
d->im_state_.composing_mode_ =
- (d->style_.segments_.size() == 0 && focus_style != nullptr)
- || (focus_style != nullptr && focus_style->length == 0)
- || (focus_style == nullptr && d->style_.segments_.size() <= 1);
+ d->caret_rel_pos_ == (pos_type)d->preedit_str_.length();
if (d->im_state_.composing_mode_) {
+ if (d->im_off_in_math_ ||
+ d->preedit_str_.empty() || !d->style_.segments_.empty())
+ return;
LYXERR(Debug::KEY, "preedit is in the composing mode");
QTextCharFormat char_format;
- int start = 0;
- size_type length = 0;
- if (focus_style != nullptr && focus_style->length != 0) {
- char_format = focus_style->value.value<QTextCharFormat>();
- char_format.setFontUnderline(true);
- start = focus_style->start;
- length = (size_type)focus_style->length;
- } else if (!d->im_off_in_math_ && !d->preedit_str_.empty() &&
- d->style_.segments_.empty()) {
- // dead keys on MacOS give no char format having preedit strings
- length = d->preedit_str_.length();
- } else
- return;
conformToSurroundingFont(char_format);
- PreeditSegment seg = {start, length, char_format};
+ PreeditSegment seg = {0, d->preedit_str_.length(), char_format};
d->style_.segments_.push_back(seg);
} else {
LYXERR(Debug::KEY, "preedit is in the completing mode");
More information about the lyx-cvs
mailing list