Bug 66172 - spell suggestion replaces wrong word
Summary: spell suggestion replaces wrong word
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: composer (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 66353 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-10-17 21:11 UTC by Daniel Naber
Modified: 2007-09-14 12:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Naber 2003-10-17 21:11:56 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

The online spell checker (the one that shows incorrect words in a blue font) sometimes replaces the wrong word if you use one of the suggestions from the RMB menu. To reproduce type some text so that there's an error in the second line. Use a suggestion and text in the first line will be replaced instead. This only happens when you ended the first line with return, not when you continue typing so that automatic word wrapping is used.
Comment 1 Daniel Naber 2003-10-21 21:10:56 UTC
*** Bug 66353 has been marked as a duplicate of this bug. ***
Comment 2 Ingo Klöcker 2003-10-31 01:48:01 UTC
Subject: kdepim/kmail

CVS commit by kloecker: 

Fix problems with replacing misspelled words. Based on patch by Daniel Naber.
CCMAIL: 66172-fixed@bugs.kde.org
CCMAIL: 66174-fixed@bugs.kde.org


  M +6 -10     kmcomposewin.cpp   1.759


--- kdepim/kmail/kmcomposewin.cpp  #1.758:1.759
@@ -5886,14 +5886,10 @@ bool KMEdit::eventFilter(QObject*o, QEve
           int parIdx = 1, txtIdx = 1;
           getCursorPosition(&parIdx, &txtIdx);
-
-          //Put in our replacement
-          QString txtContents = text();
-          QString newContents = txtContents.left(firstSpace) + mReplacements[word][id] +
-                                txtContents.right( txtContents.length() - lastSpace );
-          setText( newContents );
-
-          //Restore the cursor position
-          if( txtIdx > lastSpace )
-            txtIdx += newContents.length() - txtContents.length();
+          setSelection(para, firstSpace, para, lastSpace);
+          insert(mReplacements[word][id]);
+          // Restore the cursor position; if the cursor was behind the
+          // misspelled word then adjust the cursor position
+          if ( para == parIdx && txtIdx >= lastSpace )
+            txtIdx += mReplacements[word][id].length() - word.length();
           setCursorPosition(parIdx, txtIdx);
         }