Am 27.11.2010 um 15:32 schrieb LyX Ticket Tracker:

> #7084: Dynamic spellchecker throws "Search string is empty" exemption
> --------------------+-------------------------------------------------------
> Reporter:  guenno  |       Owner:  stwitt  
>     Type:  defect  |      Status:  accepted
> Priority:  normal  |   Milestone:  2.0.0   
> Component:  spell   |     Version:  2.0.0svn
> Severity:  normal  |    Keywords:          
> --------------------+-------------------------------------------------------
> Changes (by stwitt):
> 
>  * owner:  lasgouttes => stwitt
>  * status:  new => accepted
> 
> 
> Comment:
> 
> I can confirm that.
> 
> -- 
> Ticket URL: <http://www.lyx.org/trac/ticket/7084#comment:1>
> The LyX Project <http://www.lyx.org/>
> LyX -- The Document Processor

The patch to solve that issue is attached.

Surely, there are other ways to correct it - I propose this one.
In case of existing selection it has to be the whole word.
Ok?

Stephan

PS: 
The change of Cursor.h makes the parameter name uniform with the implementation 
in Cursor.cpp.

Index: src/frontends/qt4/Menus.cpp
===================================================================
--- src/frontends/qt4/Menus.cpp (Revision 36787)
+++ src/frontends/qt4/Menus.cpp (Arbeitskopie)
@@ -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,11 +749,13 @@
        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);
+       docstring const & selection = cur.selectionAsString(false);
        switch (res) {
        case SpellChecker::UNKNOWN_WORD:
-               if (lyxrc.spellcheck_continuously) {
+               if (lyxrc.spellcheck_continuously && (!cur.selection() || 
selection == wl.word())) {
                        LYXERR(Debug::GUI, "Misspelled Word! Suggested Words = 
");
                        size_t i = 0;
                        size_t m = 10; // first submenu index
@@ -762,7 +765,9 @@
                                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
Index: src/Cursor.h
===================================================================
--- src/Cursor.h        (Revision 36787)
+++ src/Cursor.h        (Arbeitskopie)
@@ -111,7 +111,7 @@
         */
        bool selHandle(bool selecting);
        ///
-       docstring selectionAsString(bool label) const;
+       docstring selectionAsString(bool with_label) const;
        ///
        docstring currentState() const;
 

Reply via email to