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

Find and Replace Functionality #1537

Merged

Conversation

tom-ludwig
Copy link
Member

@tom-ludwig tom-ludwig commented Dec 29, 2023

This PR adds simple search and replace functions.
The first one, searchAndReplace, can replace all occurrences of a search term across the workspace. The second, replaceRange, lets you replace text in a specific range within a file. Depending on the range, it's useful for replacing a single term in a file or even within a function.

Additional Improvements

  • Implement visual feedback in the Find Navigator to display current states such as 'Searching...', 'Replacing...', 'Found...', and 'Failed,' in compliance with Apple's human interface guidelines: Apple suggests using visual feedback to acknowledge user input and provide a clear indication that an action is taking place.
  • Remove duplicate 'Match Whole Word' option from the search text field
  • Fix bug preventing proper functionality of search options such as 'Match Word,' 'Starting with,' and 'Ending with'.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code
  • Performance improvements
  • Write some tests
    • Indexing
      • testAddProjectToIndex()
    • Find
      • testSearch()
      • testSearchWithOptionContaining()
      • testSearchWithOptionMatchingWord()
      • testSearchWithOptionStartingWith()
      • testSearchWithOptionEndingWith()
      • testSearchWithOptionCaseSensitive()
        - [ ] testSearchWithOptionRegularExpression()
    • Find And Replace
      • testFindAndReplace()
      • testFindAndReplaceWithOptionContaining()
      • testFindAndReplaceWithOptionMatchingWord()
      • testFindAndReplaceWithOptionStartingWith()
      • testFindAndReplaceWithOptionEndingWith()
        - [ ] testFindAndReplaceWithOptionRegularExpression()

Screenshots

Screenshot 2024-01-14 at 12 51 05 PM Screenshot 2024-01-14 at 12 49 14 PM Screenshot 2024-01-14 at 12 48 57 PM Screenshot 2024-01-14 at 12 48 31 PM

This commit includes 3 versions of a search and replace function;
Also removes an unnecessary map;
@tom-ludwig tom-ludwig changed the title Implemented Search and Replace Functions 1466 Search and Replace Functions 1466 Dec 29, 2023
@austincondiff austincondiff changed the title Search and Replace Functions 1466 Find and Replace Functionality Dec 29, 2023
@austincondiff austincondiff added the enhancement New feature or request label Dec 29, 2023
@austincondiff
Copy link
Collaborator

I might use checkmark.circle.fill instead of checkmark.diamond.fill. I believe diamond symbols in Xcode usually indicates tests. We should also replace searching... with a spinner indicator.

What is the difference between No Results, and An Error Occurred? The subtitle is very similar. I might also look into which symbols are being used here as well.

image

@tom-ludwig
Copy link
Member Author

I've changed the symbol and added a ProgressView().

For folks who missed the meetup: I wanted to highlight the difference between an unsuccessful search and a unsuccessful find-and-replace.

Untitled.mov

@tom-ludwig tom-ludwig marked this pull request as ready for review January 27, 2024 10:57
@tom-ludwig
Copy link
Member Author

For reviewers: The existing search and Find And Replace algorithm lacks real-time progress visibility for users, meaning it doesn't promptly display the found files or terms that have been replaced. I already have plans for an upcoming pull request where the results will be delivered incrementally (the result will be returned in chunks).

Copy link
Collaborator

@austincondiff austincondiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, and thanks for writing tests! ✅

@FastestMolasses FastestMolasses merged commit 7eece7a into CodeEditApp:main Jan 30, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Find Navigator: Replace all
4 participants