From d16a95afe7e800356150256439cc07c1c57f06f3 Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Thu, 16 Jul 2015 22:06:23 +0200 Subject: [PATCH] #9496 add a check for requested thesaurus files if thesaurusdir_path of lyxrc is empty This path configuration variable is used for user defined location. There are other possible places for the thesauri like mythes installers or bundled with LyX. --- src/Text3.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Text3.cpp b/src/Text3.cpp index 8867e10826..eb8f7a0cc2 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -44,6 +44,7 @@ #include "SpellChecker.h" #include "TextClass.h" #include "TextMetrics.h" +#include "Thesaurus.h" #include "WordLangTuple.h" #include "frontends/alert.h" @@ -2329,6 +2330,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_THESAURUS_ENTRY: { + Language const * language = cur.getFont().language(); docstring arg = cmd.argument(); if (arg.empty()) { arg = cur.selectionAsString(false); @@ -2337,10 +2339,20 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // Get word or selection selectWordWhenUnderCursor(cur, WHOLE_WORD); arg = cur.selectionAsString(false); - arg += " lang=" + from_ascii(cur.getFont().language()->lang()); + arg += " lang=" + from_ascii(language->lang()); + } + } else { + string lang = cmd.getArg(1); + // This duplicates the code in GuiThesaurus::initialiseParams + if (prefixIs(lang, "lang=")) { + language = languages.getLanguage(lang.substr(5)); + if (!language) + language = cur.getFont().language(); } } - if (lyxrc.thesaurusdir_path.empty()) { + string lang = language->code(); + if (lyxrc.thesaurusdir_path.empty() && !thesaurus.thesaurusInstalled(from_ascii(lang))) { + LYXERR(Debug::ACTION, "Command " << cmd << ". Thesaurus not found for language " << lang); frontend::Alert::warning(_("Path to thesaurus directory not set!"), _("The path to the thesaurus directory has not been specified.\n" "The thesaurus is not functional.\n" -- 2.39.2