CodeEdit icon indicating copy to clipboard operation
CodeEdit copied to clipboard

Find and Replace Functionality

Open tom-ludwig opened this issue 2 years ago • 3 comments

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

  • closes #1466

Checklist

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

tom-ludwig avatar Dec 29 '23 16:12 tom-ludwig

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

austincondiff avatar Jan 20 '24 15:01 austincondiff

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.

https://github.com/CodeEditApp/CodeEdit/assets/83090745/4e781778-e825-4427-8d90-51067c926d92

tom-ludwig avatar Jan 22 '24 07:01 tom-ludwig

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).

tom-ludwig avatar Jan 27 '24 11:01 tom-ludwig