Recent

Author Topic: [SOLVED - BUT NOT SATISFACTORILY] Better search and replace dialog...  (Read 7796 times)

GypsyPrince

  • Guest
Would it be possible to get a better search and replace dialog in the next version of Lazarus. It doesn't need to be anywhere near as fancy as the one for MS Visual Studio.  But I would like the 'Find Next' and 'Replace Next' buttons that allow me to cycle through to each occurrence of a word - to let me decide whether I want to replace that occurrence or leave it alone. The point is... I would like for the dialog to remain open after I click 'Replace' and not close until I click a close button.  It is REALLY annoying to have to reopen the dialog for each occurrence I want to replace, and using the 'Replace All' function can often be dangerous.

See attached file for example...

« Last Edit: April 05, 2020, 02:47:40 am by GypsyPrince »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Better search and replace dialog...
« Reply #1 on: April 04, 2020, 09:41:56 pm »
Would it be possible to get a better search and replace dialog in the next version of Lazarus. It doesn't need to be anywhere near as fancy as the one for MS Visual Studio.  But I would like the 'Find Next' and 'Replace Next' buttons that allow me to cycle through to each occurrence of a word - to let me decide whether I want to replace that occurrence or leave it alone. The point is... I would like for the dialog to remain open after I click 'Replace' and not close until I click a close button.  It is REALLY annoying to have to reopen the dialog for each occurrence I want to replace, and using the 'Replace All' function can often be dangerous.
You failed to notice the "Prompt on replace" checkbox.
The dialog works as well as the one in MS Visual Studio although it is different. This is not a Visual Studio clone.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Better search and replace dialog...
« Reply #2 on: April 04, 2020, 09:53:35 pm »
with the "prompt" option, you will be asked for each occurrence.  Though the prompt has its own dialog.


There is also continue - usually F3.

GypsyPrince

  • Guest
Re: Better search and replace dialog...
« Reply #3 on: April 04, 2020, 10:49:40 pm »
@Martin_fr

Quote
...with the "prompt" option, you will be asked for each occurrence.

With "Prompt on replace" checked, it asks me only one time if I would like to replace the next instance. When I select yes, the dialog closes. I need it to not close until I tell it to close.

@JuhaManninen

Quote
The dialog works as well as the one in MS Visual Studio...

No, actually it doesn't for reasons stated above. It is very inefficient in its current design.

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re: Better search and replace dialog...
« Reply #4 on: April 04, 2020, 10:53:26 pm »
@Martin_fr

Quote
...with the "prompt" option, you will be asked for each occurrence.

With "Prompt on replace" checked, it asks me only one time if I would like to replace the next instance. When I select yes, the dialog closes. I need it to not close until I tell it to close.

@JuhaManninen

Quote
The dialog works as well as the one in MS Visual Studio...

No, actually it doesn't for reasons stated above. It is very inefficient in its current design.
you need to select replace all with the prompt on replace checked.

GypsyPrince

  • Guest
Re: Better search and replace dialog...
« Reply #5 on: April 04, 2020, 10:58:04 pm »
@eljo

Quote
you need to select replace all with the prompt on replace checked.

Please re-read this from my original post.

Quote
...and using the 'Replace All' function can often be dangerous.

Using 'Replace All' can prove very bad sometimes when I don't want a specific occurrence of the word to be replaced.

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re: Better search and replace dialog...
« Reply #6 on: April 04, 2020, 10:59:39 pm »
@eljo

Quote
you need to select replace all with the prompt on replace checked.

Please re-read this from my original post.

Quote
...and using the 'Replace All' function can often be dangerous.

Using 'Replace All' can prove very bad sometimes when I don't want a specific occurrence of the word to be replaced.
just try it. Its what you want.

GypsyPrince

  • Guest
Re: Better search and replace dialog...
« Reply #7 on: April 04, 2020, 11:00:32 pm »
I have tried it.

It's not what I want.

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re: Better search and replace dialog...
« Reply #8 on: April 04, 2020, 11:01:15 pm »
I have tried it.

It's not what I want.
doesn't stop before every replace and asks for yes or no?

GypsyPrince

  • Guest
Re: Better search and replace dialog...
« Reply #9 on: April 04, 2020, 11:02:45 pm »
No. It does not. It replaces all occurrences at once.

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re: Better search and replace dialog...
« Reply #10 on: April 04, 2020, 11:03:15 pm »
No. It does not. It replaces all occurrences at once.
Then you do not have the prompt on replace checked.

GypsyPrince

  • Guest
Re: Better search and replace dialog...
« Reply #11 on: April 04, 2020, 11:06:57 pm »
Nope... wrong answer. It is selected.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Better search and replace dialog...
« Reply #12 on: April 04, 2020, 11:29:33 pm »
No. It does not. It replaces all occurrences at once.
I don't believe you now. I just tested and it works as eljo described. It has done so for ages, it cannot be a version difference issue either.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Better search and replace dialog...
« Reply #13 on: April 04, 2020, 11:30:38 pm »
I have tried it.

It's not what I want.

Then I do not know what you want.

Your image on the first post has the following buttons
- replace next
- find next

also (replace all, but I guess that is not what this is about?)

So if you press:
- Find next -> highlight the next occurrence
  if a current occurrence is already highlighted, it is not replaced
- Replace next -> replace the current occurrence, then highlight the next occurrence


That is what in Lazarus "Replace all" + Prompt does:
When you hit "Replace all", it will
- find and highlight the next occurrence.
- prompt you
  - Yes => replace and find next (and prompt again)
  - No => do not replace and find next (and prompt again)

And thus it asks for every occurrence.


Well, "replace next" sounds as if it could mean something difference.
- First search for the next.
- Then without prompt replace it.
But that would make no sense?



If I missed something, then please explain in more detail what you want.

That is other than the optical diff, if the Yes/no are in the mains search window, or in their own window; or what the label on them is.


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Better search and replace dialog...
« Reply #14 on: April 04, 2020, 11:34:48 pm »
No. It does not. It replaces all occurrences at once.
Can you make a video of it?

It has not happen to anyone I know.

Unless you did at some point select "Yes to all" => that would mean to replace all the rest, with no further prompt.


Point is, if we changed it all into one window, but keeping the existing code (which works for me, and all I know), then by all likelihood it still do the wrong thing for you.
Because either there is a bug, or you hit the wrong button (or wrong key)

 

TinyPortal © 2005-2018