Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/Search and Replace #77

Merged
merged 27 commits into from
Jun 29, 2024
Merged

Conversation

neCo2
Copy link
Contributor

@neCo2 neCo2 commented Jun 7, 2024

Adding a search and replace function. Currently accessible via a button below the editor preferences button.
The UI for search and replace uses a draggable component. The "active" surface for that is the darkened area with the title.
firefox_2024-06-07_21-15-25

Right now, it can do plaintext and regex replacements. I want to add template replacements too, but maybe I should wait for your chat completions PR for that one.

@neCo2 neCo2 marked this pull request as draft June 7, 2024 15:02
@neCo2 neCo2 changed the title Search and Replace Feature/Search and Replace Jun 7, 2024
mikupad.html Outdated Show resolved Hide resolved
@neCo2 neCo2 marked this pull request as ready for review June 8, 2024 09:20
@neCo2
Copy link
Contributor Author

neCo2 commented Jun 8, 2024

And that should be it except for the template substitution, which I'll add at a later point in time.
firefox_2024-06-08_13-27-15
Currently the replace button just replaces everything (unless you're using a non-global regex for some reason), so maybe a "replace only current match" button could be added at some point.
I'll also try to figure out how to add this to the undo stack, but feel free to do that yourself if you know a simple way.

@lmg-anon
Copy link
Owner

I'll also try to figure out how to add this to the undo stack, but feel free to do that yourself if you know a simple way.

Theoretically, you shouldn't have to do anything, it will be handled as if the user replaced the text manually.

@neCo2
Copy link
Contributor Author

neCo2 commented Jun 13, 2024

Resolved the merge conflict and changed the svgs to components.

Theoretically, you shouldn't have to do anything, it will be handled as if the user replaced the text manually.

Either I'm stupid, or it doesn't.

@lmg-anon
Copy link
Owner

Either I'm stupid, or it doesn't.

Sorry, I mean after #66 is merged. The current undo stack only supports changes made at the end of the prompt.

@lmg-anon
Copy link
Owner

lmg-anon commented Jun 16, 2024

I got around to reviewing this PR, and the code looks good to me. However, I have some suggestions for the UI:

image

  • Is the "Count" button really necessary? I think it would be fine to count as the user types.
  • The "No matches found" warning also seems unnecessary; showing "0 Matches" would be enough.
  • It's a bit odd to see "Find Next" but not "Find Last". I suggest not having the "Find Next" text.
  • The size of the widget shouldn't be relative to the prompt container (otherwise it will also resize when the prompt container is resized), so I suggest using vw/em instead of %.

Also, I see what you did with the placeholders, quite controversial lol. It's fine though, I won't pick on your creative choices.

@neCo2
Copy link
Contributor Author

neCo2 commented Jun 17, 2024

Put in the requested adjustments.
As for the placeholders, I just thought it was funny. But on second thought, some people might feel strongly enough about this to bother me, so I'll come up with something else.

@neCo2
Copy link
Contributor Author

neCo2 commented Jun 17, 2024

My vocaloid knowledge is severely lacking, but this should do.

@lmg-anon
Copy link
Owner

lmg-anon commented Jun 29, 2024

Okay, this looks good to merge, I think there are still a few things that could be improved, but I guess they could be done in other commits/PRs as needed. Thank you for the contribution! :)

@lmg-anon lmg-anon merged commit 9e5ce74 into lmg-anon:main Jun 29, 2024
@neCo2 neCo2 deleted the search-and-replace branch June 30, 2024 08:23
@neCo2
Copy link
Contributor Author

neCo2 commented Jun 30, 2024

@lmg-anon

I think there are still a few things that could be improved

Feel free to let me know what the issues are exactly.

@lmg-anon
Copy link
Owner

lmg-anon commented Jul 8, 2024

@neCo2 The only thing I would call an "issue" is how the widget resizes with the window size, becoming too big on an ultra-wide screen:
image

I guess this was my fault for suggesting vw for the widget size, probably em was the right call.

The other improvements I was considering include:

  • Highlighting the matches like how other editors do. (This would probably be hard to do)
  • Showing the current match index/count.
  • Opening the widget when you press CTRL+F or CTRL+H.
  • Adding a "Replace Next" button.
  • Adding a case sensitivity toggle.
  • Adding an option to search/replace only within the selected text.

In other words, features that are in the find/replace of softwares like VSCode:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants