#439 "Whole word" option does not work in Replace

closed-accepted
5
2014-02-06
2012-07-13
Anonymous
No

Problem:
Trying to replace all occurrences of "debug_client" with "DebugClient", when the "Whole word" option is selected in the Search&Replace dialog, causes also partial word replacements. E.g. both of the following were replaced:

genericapi: debug_client
genericapi_all: debug_client_all

Note that in the 2nd line, debug_client does not appear as a whole word.

Patch:
The _replace() method in SearchAndReplace.java file noWordSep is assigned with wordBreakChars. So i changed it to assign noWordSep

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-07-13

    Patch

     
    Attachments
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-07-14
    • summary: "Whole word" option does not work in Replace - ID: 3522497 --> "Whole word" option does not work in Replace
     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-07-14

    Hey I am creating this patch with the version 4.5.2

     
  • Jarek Czekalski

    Jarek Czekalski - 2012-07-29

    Malahti, you found and fixed an evident bug. Thanks for that. But I wonder if this change is good:

    - if (noWordSep == null)
    + if (noWordSep == null || noWordSep.isEmpty())

    That means that user will not be able to treat _ as a non-word character. Even if he leaves "Extra word characters" empty, the underscore will still be treated as being part of the word. _ is a default "Extra word character" (see jedit.props), isn't it enough?

     
  • Jarek Czekalski

    Jarek Czekalski - 2012-07-29
    • assigned_to: nobody --> jarekczek
     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-07-30

    The reason I included "noWordSep.isEmpty()" is that before changing WordBreakChars to noWordSep in _replace() the value that noWordSep get in setNoWordSep is an empty string(because wordBreakChars is empty in jedit.props). At that time if "noWordSep == null" condition only is checked, then noWordSep is assigned with the empty string. To avoid that i included "noWordSep.isEmpty()" condition as a precautionary. If I am wrong clarify me. Thanks

     
  • Jarek Czekalski

    Jarek Czekalski - 2012-07-30

    Are you saying: "it's a mistake"?

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-07-30

    Ya it is a mistake. No need for that condition. Do i have to submit the patch again without this condition?

     
  • Jarek Czekalski

    Jarek Czekalski - 2012-07-30

    I'll change it manually, no need to resubmit.

    Regarding wordBreakChars: it is set by mode. So for java files you get ,+-=<>/?^&*
    by buffer.getProperty("wordBreakChars") in BeanShell console. That means that a in a+b was not treated as a separate word and your patch will fix it as well.

     
  • Jarek Czekalski

    Jarek Czekalski - 2012-07-31
    • status: open --> closed-accepted
     
  • Jarek Czekalski

    Jarek Czekalski - 2012-07-31

    r21965

     

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

Sign up for the SourceForge newsletter:





No, thanks