Version: (using KDE KDE 3.2.0) Installed from: Compiled From Sources Compiler: gcc 3.2.2 with -O2 OS: Linux The spell checker runs through the document and flags all misspelled words, but when clicking on "Replace" or "Replace All" it does not change the text. It does however mark the document as modified, and the text it highlights after the first word seems to be offset by the number of characters that should have been inserted or deleted. Even though the document is marked modified, saving and reopening it has no effect. This is the same problem reported by Tami King on the Quanta mailing list in December '03 (https://mail.kde.org/pipermail/quanta/2003-December/002409.html). Same problem appears in ARCH 0.6 build of KDE 3.2, and compiled from source on Redhat 9. Spell check in Kate and KWord works OK. I am using aspell, but Tami King used ispell.
This is something which seems to be broken on KDE 3.2+. It works if Quanta is compiled under KDE 3.1.4, so I suspect this is a problem triggered by a change in the Kate part. So from here comes the techincal part: In Quanta we use our own spell checking implementation based on KSpell, in order to skip HTML tags while checking. The corrected() signal of KSpell is connected to the following slot: void SpellChecker::corrected( const QString& originalword, const QString& newword, uint pos ) { KTextEditor::EditInterface* editIf = dynamic_cast<KTextEditor::EditInterface*>(m_currentDoc); m_replaceCount++; uint line, col; locatePosition( pos, line, col ); QString lineText = editIf->textLine(line); lineText.remove(col,originalword.length()); lineText.insert(col, newword); editIf->removeLine(line); editIf->insertLine(line, lineText); } m_currentDoc is a KTextEditor::Document* pointing to the current document. Here is the other involved method: void SpellChecker::locatePosition( uint pos, uint& line, uint& col ) { KTextEditor::EditInterface* editIf = dynamic_cast<KTextEditor::EditInterface*>(m_currentDoc); uint cnt = 0; line = col = 0; // Find pos -- CHANGEME: store the last found pos's cursor // and do these searched relative to that to // (significantly) increase the speed of the spellcheck for( ; line < editIf->numLines() && cnt <= pos; line++ ) cnt += editIf->lineLength(line) + 1; line--; col = pos - (cnt - editIf->lineLength(line)) + 1; } I've debugged and everything seems to be good. The correct line is found, the line is read (so lineText contains the current line, which means that the correct document is handled by the editIf), yet the editIf->removeLine(line); editIf->insertLine(line, lineText); does not have any effect. :-( The line is simply not changed. It works in KDE 3.1.4, the reporter used KDE 3.2.0 and I have CVS HEAD, where it doesn't work either. Do you have an idea what can be done to make this work again? A rather important bug visible only in Quanta... Andras
CVS commit by amantia: Make the spellchecker actually replace the wrongly spelled words [#75106] CCMAIL: 75106-done@bugs.kde.org M +1 -0 ChangeLog 1.219 M +2 -3 plugins/spellchecker.cpp 1.13 --- kdewebdev/quanta/ChangeLog #1.218:1.219 @@ -17,4 +17,5 @@ - don't crash the table editor on invalid nested tables - don't crash when setting table/body/header/footer attributes for newly created tables [#74949] + - make the spellchecker actually replace the wrongly spelled words [#75106] - various parsing fixes - report bugs for "quanta" module, not for "quanta_be" --- kdewebdev/quanta/plugins/spellchecker.cpp #1.12:1.13 @@ -166,4 +166,5 @@ void SpellChecker::corrected( const QStr lineText.remove(col,originalword.length()); lineText.insert(col, newword); + m_currentDoc->setReadWrite(true); #ifdef BUILD_KAFKAPART if (editIfExt) @@ -176,7 +177,5 @@ void SpellChecker::corrected( const QStr editIfExt->editEnd(); #endif - kapp->processEvents(); -// m_currentDoc->removeText( line, col, line, col + originalword.length() ); -// m_currentDoc->insertText( line, col, newword ); + m_currentDoc->setReadWrite(false); }