Fix a possible crash on find history build

This commit is contained in:
1024jp 2017-11-10 01:23:39 +09:00
parent a881d42a97
commit e8d548143e
2 changed files with 4 additions and 3 deletions

View File

@ -8,6 +8,7 @@ Change Log
### Fixes
- Fix an issue where the syntax highlighting indicator could display twice.
- Improve general stability.

View File

@ -257,9 +257,9 @@ final class FindPanelFieldViewController: NSViewController, NSTextViewDelegate {
private func buildHistoryMenu(_ menu: NSMenu, defaultsKey key: DefaultKey<[String]>, action: Selector) {
// clear current history items
for item in menu.items where (item.action == action || item.isSeparatorItem) {
menu.removeItem(item)
}
menu.items
.filter { $0.action == action || $0.isSeparatorItem }
.forEach { menu.removeItem($0) }
guard let history = UserDefaults.standard[key], !history.isEmpty else { return }