commit f4a583b6d242aa518893d2bbccf2ed5da0133dee
Author: Koji Yokota <[email protected]>
Date:   Wed Aug 27 11:49:53 2025 +0900

    Amend commit 63be48a
---
 src/Text.cpp                        |  1 +
 src/frontends/InputMethod.h         |  4 ++++
 src/frontends/qt/GuiInputMethod.cpp | 23 +++++++++++++++++------
 src/frontends/qt/GuiInputMethod.h   |  4 ++++
 4 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index e528024bab..b71b42e6e8 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -5781,6 +5781,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                cur.resetAnchor();
                                cur.selection(true);
                                cur.top().pos() = 0;
+                               cur.bv().inputMethod()->disableInputMethod();
                        } else
                                delete inset;
                }
diff --git a/src/frontends/InputMethod.h b/src/frontends/InputMethod.h
index 6e46387f72..60393c138b 100644
--- a/src/frontends/InputMethod.h
+++ b/src/frontends/InputMethod.h
@@ -79,6 +79,10 @@ public:
        virtual bool canWrapAnywhere(pos_type const char_format_index) = 0;
        ///
        virtual void toggleInputMethodAcceptance() = 0;
+       ///
+       virtual void enableInputMethod() = 0;
+       ///
+       virtual void disableInputMethod() = 0;
 #ifdef Q_DEBUG
        ///
        virtual void setHint(Hint) = 0;
diff --git a/src/frontends/qt/GuiInputMethod.cpp 
b/src/frontends/qt/GuiInputMethod.cpp
index fad4538444..2c85760a71 100644
--- a/src/frontends/qt/GuiInputMethod.cpp
+++ b/src/frontends/qt/GuiInputMethod.cpp
@@ -23,7 +23,6 @@
 #include "GuiFontLoader.h"
 #include "GuiWorkArea.h"
 #include "InsetList.h"
-#include "mathed/InsetMathMacro.h"
 #include "KeyMap.h"
 #include "Language.h"
 #include "LyX.h"
@@ -132,12 +131,10 @@ void GuiInputMethod::toggleInputMethodAcceptance(){
                        d->cur_->getFont().language()->inputMethodOffInMath();
 
        // note that d->cur_->inset() is a cache so it lags from actual key 
moves
-       bool inMathMode = d->cur_->inset().currentMode() == Inset::MATH_MODE;
-       bool inMathMacro = d->cur_->inset().asInsetMath() != nullptr &&
-                          d->cur_->inset().asInsetMath()->asMacroInset() != 
nullptr;
        bool enabled =
-               !((d->im_off_in_math_ && (inMathMode || inMathMacro)) ||
-                 guiApp->isInCommandMode());
+               !((d->im_off_in_math_
+                  && d->cur_->inset().currentMode() == Inset::MATH_MODE)
+                 || guiApp->isInCommandMode());
        if (enabled != d->im_state_.enabled_) {
                d->im_state_.enabled_= enabled;
                Q_EMIT inputMethodStateChanged(Qt::ImEnabled);
@@ -145,6 +142,20 @@ void GuiInputMethod::toggleInputMethodAcceptance(){
 }
 
 
+void GuiInputMethod::enableInputMethod()
+{
+       d->im_state_.enabled_= false;
+       Q_EMIT inputMethodStateChanged(Qt::ImEnabled);
+}
+
+
+void GuiInputMethod::disableInputMethod()
+{
+       d->im_state_.enabled_= false;
+       Q_EMIT inputMethodStateChanged(Qt::ImEnabled);
+}
+
+
 void GuiInputMethod::onLocaleChanged()
 {
        const std::string im_locale_code = 
fromqstr(d->sys_im_->locale().name());
diff --git a/src/frontends/qt/GuiInputMethod.h 
b/src/frontends/qt/GuiInputMethod.h
index b339de903e..cf07d88749 100644
--- a/src/frontends/qt/GuiInputMethod.h
+++ b/src/frontends/qt/GuiInputMethod.h
@@ -127,6 +127,10 @@ public Q_SLOT:
        void processQuery(Qt::InputMethodQuery query);
        /// Turn off IM in math mode and command phase and turn it on otherwise
        void toggleInputMethodAcceptance() override;
+       /// Enable the input method
+       void enableInputMethod() override;
+       /// Disable the input method
+       void disableInputMethod() override;
        /// Handles the localeChanged() signal the input method emits
        void onLocaleChanged();
        void onCursorPositionChanged();
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to