Now that documents selected in the file browser can be searched, we can end up with a document path in the ‘otherFolder’ property.
This would happen by selecting a document in the file browser, opening the find dialog, and then selecting this document in the pop-up, as it is listed in the pop-up with a menu item tag of “FFSearchTargetOther”.
The Replace All button’s enabled state is based on count of matches (via bindings), so unbinding would leave it possibly enabled when it should have been disabled.
This is to avoid an exception when the code is used with menu items that have no represented object (which it normally wouldn’t in shipping code, but it seems it should be supported nonetheless).
The system can be updating the menu only to resolve a key equivalent, hence the image is not required. The document icon can be a little expensive to create because of the SCM badge. This would be noticeable when doing a folder search with hundres or thousands of results and then pressing ⌘1, here it would previously need to create all the document icons before responding to the key.
Since we do not load documents before the user selects them, e.g. after session restore or when opening multiple documents, it makes sense to have both an isOpen and isLoaded property, the former means “is shown somewhere in the UI” and would make it appear (e.g. in file browser) with close button etc., whereas the latter means that data has been loaded from disk, and we can safely access the buffer.
It looks better when we have a “full page” of results on the first update, rather than building up the first page of results file-by-file with only 0.03 seconds between each “increment”.
Since the checkbox button shown in the search results had its values bound directly to an FFResultNode instance, it would retain this object for as long as the checkbox was around, which is basically forever, although it could be reused with another FFResultNode instance, in which case the previous instance would be released.
To avoid this, we have introduced an NSTableCellView that stores the FFResultNode instance as its object value, and the checkbox uses a key path that goes via the object value for the bound values. This still creates a retain cycle, but the NSOutlineView will set all object value properties to nil when its data is cleared, thereby at least releasing the FFResultNode objects.
This requires the document search to be stopped explicitly rather than released, but I think this is an acceptable requirement. If it is not stopped, the search will simply run its course, which would also have been the case, if something else was retaining the object.
The motivation for this was so that we can see if we match whitespace, e.g. searching for trailing whitespace using ‘[\t ]+$’ would not indicate how much whitespace we actually matched.
Two minor changes:
- Matches now (correctly) use a font with monospace digits for all line numbers (not just first).
- Matches with ‘\r’ characters now have the replacement string (‘<CR>’) be bold if it is part of the match.
The existing ‘attr_string_t’ is a little inflexible in that it has to know how to handle each attribute type and also lack a way to push/pop styles, which means that in practice we have to reset styles when leaving a scope.
This will expand the replace (format) string using the captures of each match and copy each expansion to the pasteboard.
For example searching for `object->(\w+)\()` with replace set to `$1` will copy only the function name from each invocation.