commit b18fff0caa5c44e1d2d7b8c10bf4d5146c95a971
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Wed Jun 3 12:14:30 2015 +0200

    When the document language is changed, update cursor language too
    
    Actually, the change is done only if the cursor language was the
    document language already.
    
    This fixes an trivial but annoying problem: create a new file (in
    English), change language to your favourite language, then start to
    write. Before this fix, the words come out in English, which does not
    make sense.
    
    Fixes bug #9586.

diff --git a/src/frontends/qt4/GuiDocument.cpp 
b/src/frontends/qt4/GuiDocument.cpp
index 76c8585..e19ec52 100644
--- a/src/frontends/qt4/GuiDocument.cpp
+++ b/src/frontends/qt4/GuiDocument.cpp
@@ -31,6 +31,7 @@
 #include "BufferView.h"
 #include "Color.h"
 #include "ColorCache.h"
+#include "Cursor.h"
 #include "Encoding.h"
 #include "FloatPlacement.h"
 #include "Format.h"
@@ -2593,9 +2594,16 @@ void GuiDocument::applyView()
        bp_.quotes_language = (InsetQuotes::QuoteLanguage) 
langModule->quoteStyleCO->itemData(
                langModule->quoteStyleCO->currentIndex()).toInt();
 
-       QString const lang = langModule->languageCO->itemData(
+       QString const langname = langModule->languageCO->itemData(
                langModule->languageCO->currentIndex()).toString();
-       bp_.language = lyx::languages.getLanguage(fromqstr(lang));
+       Language const * newlang = 
lyx::languages.getLanguage(fromqstr(langname));
+       Cursor & cur = const_cast<BufferView *>(bufferview())->cursor();
+       // If current cursor language was the document language, then update it 
too.
+       if (cur.current_font.language() == bp_.language) {
+               cur.current_font.setLanguage(newlang);
+               cur.real_current_font.setLanguage(newlang);
+       }
+       bp_.language = newlang;
 
        QString const pack = langModule->languagePackageCO->itemData(
                langModule->languagePackageCO->currentIndex()).toString();
diff --git a/status.21x b/status.21x
index c343042..f94647c 100644
--- a/status.21x
+++ b/status.21x
@@ -68,6 +68,8 @@ What's new
 - Fix automatic insertion of longtable captions (bug 9692).
 
 - Fix setting of nested minipage via the dialog (bug 8716).
+
+- When the document language is changed, update cursor language too (bug 9586).
  
 
 * INTERNALS

Reply via email to