#7084 provide spelling suggestions only when replacement is possible - if there is no selection or the misspelled word is selected; use the replace2string to construct the LFUN arguments

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36834 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stephan Witt 2010-12-11 19:10:44 +00:00
parent cb1fc51b9c
commit 937984898a

View File

@ -44,6 +44,7 @@
#include "LyXAction.h"
#include "LyX.h"
#include "LyXRC.h"
#include "lyxfind.h"
#include "Paragraph.h"
#include "ParIterator.h"
#include "Session.h"
@ -748,12 +749,15 @@ void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
docstring_list suggestions;
pos_type from = bv->cursor().pos();
pos_type to = from;
Paragraph const & par = bv->cursor().paragraph();
Cursor const & cur = bv->cursor();
Paragraph const & par = cur.paragraph();
SpellChecker::Result res = par.spellCheck(from, to, wl, suggestions, true, true);
switch (res) {
case SpellChecker::UNKNOWN_WORD:
if (lyxrc.spellcheck_continuously) {
LYXERR(Debug::GUI, "Misspelled Word! Suggested Words = ");
docstring const & selection = cur.selectionAsString(false);
if (!cur.selection() || selection == wl.word()) {
size_t i = 0;
size_t m = 10; // first submenu index
MenuItem item(MenuItem::Submenu, qt_("More Spelling Suggestions"));
@ -762,7 +766,9 @@ void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
docstring const & suggestion = suggestions[i];
LYXERR(Debug::GUI, suggestion);
MenuItem w(MenuItem::Command, toqstr(suggestion),
FuncRequest(LFUN_WORD_REPLACE, suggestion));
FuncRequest(LFUN_WORD_REPLACE,
replace2string(suggestion,selection,
true, true, false, false)));
if (i < m)
add(w);
else
@ -778,6 +784,7 @@ void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
add(MenuItem(MenuItem::Command, qt_("Ignore all|I"),
FuncRequest(LFUN_SPELLING_IGNORE, arg)));
}
}
break;
case SpellChecker::LEARNED_WORD: {
LYXERR(Debug::GUI, "Learned Word.");