#42 QDocumentSearch and backward

QCodeEdit (16)

I have the text
aaa <bbb| ccc ddd

the cursor is |
If i search backward the regexp [^A-Za-z0-9:\.\-], the text will not be find.

I correct in the attached file.

If i search backward, with next method, the returned cursor is at position 4 (and not 5) and the cursor doesn't select text because of clearSelection.

My goal is
QDocumentCursor XinxCodeEdit::find ( const QRegExp & expr, const QDocumentCursor & cursor, XinxCodeEdit::FindFlags options ) const {
QDocumentSearch::Options opt = QDocumentSearch::Silent | QDocumentSearch::RegExp | QDocumentSearch::CaseSensitive;
if( options.testFlag( FindWholeWords ) ) opt |= QDocumentSearch::WholeWords;
QDocumentSearch searchEngine( m_editor->editor(), expr.pattern(), opt );

searchEngine.setCursor( cursor );
searchEngine.next( options.testFlag( FindBackward ) );
return searchEngine.cursor();

QDocumentCursor before ( find ( QRegExp( "[^A-Za-z0-9:\.\-]" ), cursor, XinxCodeEdit::FindBackward ) );
QDocumentCursor after ( find ( QRegExp( "[^A-Za-z0-9:\.\-]" ), cursor ) );

before must return the char < before bbb and after must return the space after bbb.

I have change the document file attached (and uncomment a text, is there a bug with this uncomment text ?).



  • fullmetalcoder

    fullmetalcoder - 2009-01-04
    • assigned_to: nobody --> fullmetalcoder
  • fullmetalcoder

    fullmetalcoder - 2009-01-04
    • status: open --> open-fixed
  • fullmetalcoder

    fullmetalcoder - 2009-01-04

    Thanks for your report and for your fix.
    The modifications have been applied to SVN trunk.

    however please send a diff/patch next time rather than the whole file : it is smaller and allows easier mergin/reviewing of the patch.



  • Ulrich Van Den Hekke

    I have some problem, if more than one same word is on one line (and i search this line) and in some case (backward search of aaa in text :
    aaa abc abbb aaa acc add abc\n avc acc arc aaa aca aaa abb bbb ccc\n aaa abc abac aaax aee
    test in Ceci est un test, ce test est doit me compter 3 mots test)

    To resolve the problem see the patch attached.

  • fullmetalcoder

    fullmetalcoder - 2009-01-07

    I am unable to reproduce the problem with latest SVN trunk. Either you did not update your working copy recently enough or there have been a problem when updating it (such as improper merging done by whichever tool you used to perform the update if your local version of the file had changes).

  • Ulrich Van Den Hekke

    I work on the last SVN trunk. I attach a video to see the bug without the patch.

  • fullmetalcoder

    fullmetalcoder - 2009-01-07

    the bug actually lied in cursor movement (QDocumentCursor::PreviousBlock was not handled correctly when reaching the first document line) and has been fixed in r816.

    thanks for your help.

  • fullmetalcoder

    fullmetalcoder - 2009-02-16
    • status: open-fixed --> closed-fixed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks