Add hs.spotlight#70
Conversation
Greptile SummaryAdds
Confidence Score: 3/5Safe to merge after fixing the predicate crash; all other code is well-structured and thoroughly tested. The
Important Files Changed
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
Hammerspoon 2/Modules/hs.spotlight/HSSpotlightQuery.swift:344-347
`NSPredicate(format:)` treats its argument as a printf-style format string. A user-supplied predicate that happens to contain `%@`, `%d`, `%K`, or any other valid format specifier—e.g. `kMDItemFSName == 'Report%20Final.pdf'` or `kMDItemWhereFroms CONTAINS '%40gmail'`—will crash at the moment the format string is parsed, because no corresponding varargs are provided. Use `NSPredicate(fromMetadataQueryString:)`, which is specifically designed to parse raw Spotlight MDQuery expression strings without format-string interpolation.
```suggestion
let wasRunning = isRunning
if wasRunning { query.stop() }
guard let pred = NSPredicate(fromMetadataQueryString: predicate) else {
AKError("hs.spotlight.setQuery(): invalid predicate syntax — \(predicate)")
if wasRunning { _ = start() }
return self
}
query.predicate = pred
if wasRunning { _ = start() }
```
Reviews (1): Last reviewed commit: "Add hs.spotlight" | Re-trigger Greptile |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
No description provided.