Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread An idiot's request
Mon, Jul 4 2016 9:37 AMPermanent Link

Matthew Jones

I just tried to tidy some code by replacing ':' with ' :'. I was then
going to replace double spaces with single, but instead it looped
continously and stopped responding. Daft, I know. So to fix it I
replaced ':' with '$:' and did the same darned thing. Which made me
ponder posting a request here. The two strings are available at the
beginning, and the IDE could spot that one is in the other, and say you
are stupid. Or it could self-limit to one loop around the file. Or
something. It would save idiot like me a bit of trouble...

--

Matthew Jones
Tue, Jul 5 2016 7:37 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< I just tried to tidy some code by replacing ':' with ' :'. I was then going to replace double spaces with single, but instead it looped continously and stopped responding. Daft, I know. So to fix it I replaced ':' with '$:' and did the same darned thing. Which made me ponder posting a request here. The two strings are available at the beginning, and the IDE could spot that one is in the other, and say you are stupid. Or it could self-limit to one loop around the file. Or something. It would save idiot like me a bit of trouble... >>

This is a known bug.  Unfortunately, it won't be fixed in 2.05 initially because it's actually a lot more complicated to fix than you would think. Smile

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Jul 5 2016 10:28 AMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

>  because it's actually a lot more complicated to fix than you would
> think. Smile

I'm sure it is - having written a word processor with lots of bells and
whistles beyond normal, I understand. However, it might be easy to make
a simple warning because you can simply do a search in the replace
string for the search string, and if present, you know it will loop. A
simple "are you sure you want to go into an infinite loop" question
would stop it causing loss of edits.

--

Matthew Jones
Wed, Jul 6 2016 7:38 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< However, it might be easy to make a simple warning because you can simply do a search in the replace
string for the search string, and if present, you know it will loop. A simple "are you sure you want to go into an infinite loop" question would stop it causing loss of edits. >>

You just described the entire problem.  The replace operation, itself, can cause a transformation that results in another match, causing another loop.  You have to actually keep track of exactly what was replaced and where, and do some checks to see if you're hitting the same thing over and over again.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jul 6 2016 8:32 AMPermanent Link

Boris B

Wouldn't one have to use a "cursor" of sorts, to find the first match, replace it, and then continue from the next character after that matched block?  This is as opposed to any sort of Regex or String ReplaceAll...

That way you're always moving forward, with what's been searched and replaced always in the rearview mirror.

If one starts midway in the document and wraps back around to the top (like MS Word supports), then you'd have to treat only the text block up to the starting position.

Or am I thinking too simplistically and missing something....? (I haven't had my morning coffee yet, lol!)
Thu, Jul 7 2016 7:56 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Boris,

<< If one starts midway in the document and wraps back around to the top (like MS Word supports), then you'd have to treat only the text block up to the starting position.

Or am I thinking too simplistically and missing something....? (I haven't had my morning coffee yet, lol!) >>

It's a little more complicated than that because the "start" will shift as the contents change, but yes, you're thinking right and I will probably end up doing something like that.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jul 7 2016 10:55 AMPermanent Link

Boris B

Given it's International Flog A Dead Horse Day...

The next starting position would be offset by the difference in the length of the search text and the replace text...

=)
Mon, Jul 11 2016 8:35 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Boris,

<< The next starting position would be offset by the difference in the length of the search text and the replace text... >>

Smile Yes, that part was easy.  It's the internal implementation of the code editor that gets in the way after that.

Tim Young
Elevate Software
www.elevatesoft.com
Image