Author Topic: Replace with RegEx with Preview corrupting file ...  (Read 1145 times)

rgloden

  • Senior Community Member
  • Posts: 153
  • Hero Points: 5
Replace with RegEx with Preview corrupting file ...
« on: May 07, 2016, 07:21:32 am »
SE 20.0.1.3 64-bit Windows 7; CUA; Language C++

Looks like SE with complicated multiline Replace RegEx and "Preview All" is corrupting the bottom of the file ... seem like when the Preview Replace action deleted text, it didn't change the buffer size so a section of lines at the bottom of the file are repeated.

Skipping "Preview All", the corruption doesn't seem to occur.

Also when experimenting trying to replicate for this writeup, sometimes after doing "Undo's" to get back to the pre-change state so I could repeat, the "Preview All" wouldn't show any matches, e.g. "Total replaces: 0" though Replace would work as expected.  Saving the file to disk would "fix" the state and Preview would start working again.

Setup: 
Replace
Perl RegEx
Search string: //\s+\|-+\s+//\s\|\s*//\s+\|\s+Abstract:\s+//\s+\|\s+
Note: Had to retype in the regEx but eyeballing it looks close.  Simple Multi-Line RegEx might do the same.
Replace with: Blank
List matching lines once only
Highlight replace text
List replaced matches

File contains multiple sections similar to:
   // |--------------------------------------------------------
   // |
   // | Abstract:
   // |
   // |---------------------------------------------------------

Click "Preview All"
Click through a few "NextDiff"
Then Click "Save All"
« Last Edit: May 07, 2016, 07:42:44 am by rgloden »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4120
  • Hero Points: 287
Re: Replace with RegEx with Preview corrupting file ...
« Reply #1 on: May 07, 2016, 12:59:00 pm »
Can you post a sample file?

Couldn't repro with text above although I'm may be doing something wrong.
« Last Edit: May 07, 2016, 02:06:30 pm by Clark »

rgloden

  • Senior Community Member
  • Posts: 153
  • Hero Points: 5
Re: Replace with RegEx with Preview corrupting file ...
« Reply #2 on: May 07, 2016, 11:14:39 pm »
Here is a sampleFile.  sampleFile also contains the regEx used.

Probably should have mentioned running 20.0.1.3 Hot Fix Rev 7

Also: Don't need to "NextDiff", just
   Click "Preview All"
   Click "Save All"
« Last Edit: May 08, 2016, 02:34:31 am by rgloden »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4120
  • Hero Points: 287
Re: Replace with RegEx with Preview corrupting file ...
« Reply #3 on: May 08, 2016, 04:21:01 am »
Thanks for the test file. Everything looks fine until is click "Save All". Very odd. Especially since the result file in the right pane looks totally correct. After I click "Save All" there is some duplicated file data appended to the end. I'm using 20.0.2.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4120
  • Hero Points: 287
Re: Replace with RegEx with Preview corrupting file ...
« Reply #4 on: May 08, 2016, 01:00:32 pm »
This is a really old bug.  "Save All" in the Preview dialog just doesn't handle files correctly that get shorter. It was really simple to fix it. We will build a new hot fix for this.

Thanks for finding this!

rgloden

  • Senior Community Member
  • Posts: 153
  • Hero Points: 5
Re: Replace with RegEx with Preview corrupting file ...
« Reply #5 on: May 08, 2016, 06:46:41 pm »
I know that multi-line searches are kind of a corner case ... but here are a couple more quirks:
1) The "Total found" shows the total lines found instead of the number of occurrences of the expression.
2) The Search results only displays the first line of the multi-line search expression match.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4120
  • Hero Points: 287
Re: Replace with RegEx with Preview corrupting file ...
« Reply #6 on: May 08, 2016, 10:07:05 pm »
1) The "Total replaces" shows the right count for me. I'm may not understand what you are pointing out.
2) Not sure what's best here. Should probably do the  "some-text...more-text" thing that we do when we list clipboards line by line.
« Last Edit: May 08, 2016, 11:19:58 pm by Clark »

rgloden

  • Senior Community Member
  • Posts: 153
  • Hero Points: 5
Re: Replace with RegEx with Preview corrupting file ...
« Reply #7 on: May 21, 2016, 11:06:15 pm »
Hmmm ... I can't replicate the "Total Found" issue with 20.0.2.1.  So I went back to 20.0.1 ... and I can't replicate it there either.