#3726 a in aa at eol treated as whole word in search and replace

closed-fixed
None
5
2012-10-11
2012-07-29
Jarek Czekalski
No

Steps to reproduce:
1. jedit r21961, linux, -nosettings -noplugins
2. type aa
3. invoke search
4. search for a, replace with A, check Whole word
5. replace all

You get aA, while you expected aa. It happens also at eol, for example:

aA
aaA
ababa
aA

(ababa line here is treated correctly, no replace done)

Discussion


  • Anonymous
    2012-07-30

    Ya this problem also occurs in the following scenario also:

    Input:
    twinkletwinkle little star
    how i wonder what you are

    search for twinkle and check 'whole word' option in the search and replace dialog and replace it with string "help"

    The output is:

    twinklehelp little star
    how i wonder what you are

    And i am working on this bug. Will submit a patch soon.

     

  • Anonymous
    2012-07-30

    If the nextMatch() method in BoyreMooreSearchMatcher.java finds a match and it is not a whole word(provided wholeWord option is checked in SearchAndReplace dialog) then the function calls itself recursively with the new text starting at the end of the match found.

    Input :
    twinkletwinkle little star
    how i wonder what you are

    first nextMatch() finds the first twinkle and then finds it is not a wholeword. so it will send the new text:
    twinkle little star
    how i wonder what you are
    Now the word twinkle is found once again and it is returned as a whole word now. So when we find or replace we get the second 'twinkle'.
    To avoid this my idea is to skip the current word if it has a substring that matches the text to be found if the whole word option is enabled.

    Anyone has any other better ideas?

     
    • assigned_to: nobody --> kpouer
    • status: open --> open-fixed
     
  • Fixed in rev 22347

     
    • status: open-fixed --> closed-fixed