From 25913aaac6c294f96963f117158220dbb408e2a4 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 3 Jun 2015 12:14:30 +0200 Subject: [PATCH] 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. --- src/frontends/qt4/GuiDocument.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 18b1ddfbe6..bfda9ef076 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" @@ -2604,9 +2605,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())->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();