Author Topic: Multiline Search & Replace  (Read 36627 times)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Multiline Search & Replace
« Reply #15 on: November 10, 2009, 07:14:48 am »
Sorry for the late reply.

Yes some problems:

if I do a "normal" search and replace it works, but if I try to use a regex (replace a part of the search string with \(.*\) )it does not find any matches.

More weired: if I change the line-endings to CR in one of my files and run s&r then, it also does not find anything, but changes all line-endings, that might be okay, because of the conversion to unique line-endings, but if I now open any of my project-files, all the line-endings are changed on first view of the file (if the editor gets active), I did not change the global line-ending settings, only the settings of the file in the edit-menu.

EDIT:

The last thing also happens in clean C::B, but only seems to happen, if the file I come from (last active editor) has CR-line-endings.
I think I should look into this issue at another place.

@Rick:
is it okay for you to push the patch on my server, so others can test it too ?
« Last Edit: November 10, 2009, 07:18:49 am by jens »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Multiline Search & Replace
« Reply #16 on: November 10, 2009, 02:47:15 pm »
Okay, here are my tests so far.

Normal, single-line S&R: Works.
Regex, single-line S&R: Works.
Normal, multi-line S&R: Works.
Regex, multi-line S&R: Works.

Did you check your Editor settings? I've tried with both "Extended Regex search" checked and unchecked, and handling files with both LF and CRLF endings. This on both Linux and Windows. (I think CR-only line endings are quite obsolete now. I don't think C::B has been fully tested in this case, mac OS now uses LF ending as default since the Freebsd adoption).

I've also noticed some issues, both in C::B and in my patch.

1) (C::B) In single-line S&R, (.*) INCLUDES the EOL chars. I need to use ([^\r\n])* to do a good find&replace. Perhaps we should add another option to EXCLUDE the CR and LF from regex search.  Just a thought.

2) (My patch) The S&R in files uses a different approach than the single file S&R to fix line endings. The single-file changes the file's EOL according to the global editor settings (or at least to the value of Manager::Get()->GetConfigManager(_T("editor"))->ReadInt(_T("/eol/eolmode"). The multiple file S&R changes only the search and replace expression's EOL mode. I think that in single-file, we should convert the file's line endings not to the global line endings, but to the file's line endings (just to change as few lines as possible before searching) and still achieve an effective S&R.

3) (My patch) This problem happens in the S&R dialog. First, if you enter a very large regex expression in the combos, the dialog becomes HUGE because it adjusts the width AFTER loading the data, not BEFORE. I need to fix that.

4) (My patch) Another problem I've noticed is that tab navigation doesn't work correctly on Windows. It jumps from "search from:" to the options, and i have to press shift-tab to jump to "replace to:". This doesn't happen under Linux. WTH??

5) I'm also considering making a change in cbFindReplaceData and give it methods for EOL conversion. I plan to add it an EOLMode variable and methods for conversion, like SetEOLMode(int mode). This will clean up EOL conversion in replacedlg.cpp and will prepare for a multiline Find-only dialog in the future. I'll work on it tonight.

So, how do I commit to Jens' server? I want to share my patch and allow others to help me fixing the UI problems. Jens, I might need you to give me an authentication so we can all fix this patch's issues.

Jens, please pm me with the data on your repo. Meanwhile, feel free to commit my patch on your server, but I might change some code again.

Thanks!
« Last Edit: November 10, 2009, 03:00:24 pm by rickg22 »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Multiline Search & Replace
« Reply #17 on: November 11, 2009, 03:28:34 pm »
I did some modifications to EditorManager to clean up my changes:

1) Files are checked for consistent EOLs, but if no replacements were
made (and if the file was not open), files are closed correctly.
2) I'm using the file's EOL mode to search, and not the global EOL mode.
3) The EOL conversion is not shown in the change history (the colored
bar at the left of the file).
4) For a find-only search, I convert the cbReplaceData's strings to
the current file's EOL mode.

I submitted the patch to Jens. Since this patch seems to be permanent, I hope it will be submitted to trunk.

I'll still be working on the replace dialog to make it more user friendly, and hopefully, fix the tabbing quirks on win32.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Multiline Search & Replace
« Reply #18 on: November 11, 2009, 03:38:49 pm »
1) Files are checked for consistent EOLs, but if no replacements were
made (and if the file was not open), files are closed correctly.
Are you aware that we have an option concerning the handling EOL's? Does that still work after that modification? I would not recommend to change it "silently". Because you cause a non-functional difference in the files on every platform in the worst case scenario.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Multiline Search & Replace
« Reply #19 on: November 12, 2009, 05:30:13 am »
1) Files are checked for consistent EOLs, but if no replacements were
made (and if the file was not open), files are closed correctly.
Are you aware that we have an option concerning the handling EOL's? Does that still work after that modification? I would not recommend to change it "silently". Because you cause a non-functional difference in the files on every platform in the worst case scenario.

Yes, this is only done for multi-line S&R. If the search string has no eol's (current behavior), no conversion is done. Also, he files' EOLs are not changed to the current user's but the file's (just the same as "ensure consistent EOL's menu option).

But you're absolutely right. The user must have complete control of the situation. I'm going to add an option to let the user choose whether to preprocess EOL's before searching.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Multiline Search & Replace
« Reply #20 on: November 12, 2009, 06:23:01 am »
I submitted the patch to Jens. Since this patch seems to be permanent, I hope it will be submitted to trunk.
Reminds me: Why not to the patch tracker? If you do that we all can try from day one basically. Jens seems rather busy atm (so am I)...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Multiline Search & Replace
« Reply #21 on: November 13, 2009, 04:47:26 am »
Ah, right. I need to relogin to berlios.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Multiline Search & Replace
« Reply #22 on: November 13, 2009, 06:56:01 am »
Okay, I've submitted the patch to berlios. The patch can be found at http://developer.berlios.de/patch/download.php?id=2849

WARNING! The patch _IS_ buggy (at least on Windows: the UI is having tab problems). Windows users are welcome to test it and fix it. It's got to do with the pseudo-notebook panels (single-line / multiline). Also, the multiline search tab for only-files makes the input boxes too small because of the scrollbars, assigning them a bigger size will fix it.

I've added some internal features to editormanager, namely, the ability to search only the current file (useful for listing ALL matches in the file, in find-in-files), the ability to search for beginning-of-file matches, and the option to fix mixed EOLs while searching. None of these options are active unless the finddlg and replacedlg add them to the UI.

I'm planning to change the UI and make it wider so that the extra options can fit in the dialog, but I have to go to sleep now.

Good night! :)
« Last Edit: November 13, 2009, 06:57:37 am by rickg22 »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Multiline Search & Replace
« Reply #23 on: November 18, 2009, 03:54:21 pm »
I've submitted a revised patch to berlios. It looks prettier and not that bulky, but still needs a bit of win32 tweaking. Unfortunately, I've been unable to fix the weird tabbing bug on windows. Why does it only happen on windows?

Can the patch still be applied with this usability problem?

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: Multiline Search & Replace
« Reply #24 on: November 19, 2009, 02:53:18 am »
I've submitted a revised patch to berlios. It looks prettier and not that bulky, but still needs a bit of win32 tweaking. Unfortunately, I've been unable to fix the weird tabbing bug on windows. Why does it only happen on windows?

Can the patch still be applied with this usability problem?


Is something relatived to this?http://forums.codeblocks.org/index.php/topic,11519.0.html
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Multiline Search & Replace
« Reply #25 on: November 19, 2009, 04:30:41 am »
I've submitted a revised patch to berlios. It looks prettier and not that bulky, but still needs a bit of win32 tweaking. Unfortunately, I've been unable to fix the weird tabbing bug on windows. Why does it only happen on windows?

Can the patch still be applied with this usability problem?


Is something relatived to this?http://forums.codeblocks.org/index.php/topic,11519.0.html

No, this is on a dialog using 100% native wxWidgets controls. Thanks for trying, tho :)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Multiline Search & Replace
« Reply #26 on: November 19, 2009, 04:07:35 pm »
I've been having inconsistent behavior with my windows build of C::B, I think my windows development environment is somewhat faulty. Therefore I don't even know whether it's actually my code that's failing. I need a windows user to test my multiline S&R patch.

Thank you.

UPDATE: It's fixed!!!! The tabbing problem was finally fixed. It was a style badly set in the  xrc. Tonight, maybe tomorrow, I'll fix some minor visual details and upload the final version of the patch.
« Last Edit: November 19, 2009, 04:49:39 pm by rickg22 »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Multiline Search & Replace
« Reply #27 on: November 20, 2009, 07:13:48 am »
The final patch for the Multiline S&R has been uploaded!

I mailed Jens so he can commit it to trunk. Cross your fingers! ;-)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Multiline Search & Replace
« Reply #28 on: November 20, 2009, 09:01:10 am »
The final patch for the Multiline S&R has been uploaded!
Good work, Rick! I'll apply this now in my local copy for testing. I am looking forward to it... :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Re: Multiline Search & Replace
« Reply #29 on: December 01, 2009, 02:41:00 pm »
The final patch for the Multiline S&R has been uploaded!
Good work, Rick! I'll apply this now in my local copy for testing. I am looking forward to it... :-)

Any update?