CodeEdit icon indicating copy to clipboard operation
CodeEdit copied to clipboard

Search Results UI Fixes

Open thecoolwinter opened this issue 3 years ago • 0 comments

Description

This PR finishes the search results UI changes in #549 and #534. It improves contrast between the search match and the rest of the search result, and shortens search results to 60 characters before and after the matching search result. This removes lengthy search results when searching minimized files.

While implementing the UI changes, I found that NSAttributedString crashes when given non-valid strings. The changes in WorkspaceDocument+Search.swift are the changes made to filter out non-compatible strings (It also resulted in a massive performance boost, searching the entire CodeEdit code base only takes ~1/2s now).

Changes in detail:

  • Changed search result labels to more closely match Xcode in terms of font and color.
  • Selecting search results opens the corresponding file.
  • Pressing the backspace or delete button when a result is selected will delete that result.
  • Implemented an NSOutlineView-backed search results list
  • Modified the search results to return a slightly different result structure
    • Results now look like File > Array of matches w/ line numbers. Check SearchResultModel and SearchResultMatchModel in the search module for more.
  • Added a searchResultCount variable to the search state due to the updated result structure.
  • Modified OutlineTableViewCell to be more generalized and reusable (It's used in the search list for the file header)
    • Cell now manages the icon, icon color, and file label settings instead of the OutlineTableView
  • Adds a String.safeOffset method for safely fetching an offset (this is limited to the Search module)

Related Issue

  • #534
  • Replaces PR #549

Checklist

  • [x] I read and understood the contributing guide as well as the code of conduct
  • [x] My changes generate no new warnings
  • [x] My code builds and runs on my machine
  • [x] I documented my code
  • [x] Review requested

Screenshots

Light Mode Search List. Screen Shot 2022-07-30 at 3 49 18 PM Dark Mode Search List. Screen Shot 2022-07-30 at 3 49 32 PM

thecoolwinter avatar Jul 30 '22 21:07 thecoolwinter