浏览代码

【左边栏】- 搜索记录10条只显示9条的问题修复。

liaoxiaoyue 1 年之前
父节点
当前提交
d5b9d678d2

+ 5 - 4
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/Search/KMSearchViewController.swift

@@ -137,14 +137,15 @@ class KMSearchViewController: NSViewController, NSTextFieldDelegate, NSSearchFie
         let searchString = self.searchTextField.stringValue
         
         if searchString != "" {
-            if searchs.count == 10 {
-                searchs.remove(at: 9)
-            }
-            
             //缓存搜索词汇是否重复
             if searchs.contains(searchString) {
                 searchs.removeObject(searchString)
             }
+            
+            if searchs.count == 10 {
+                searchs.remove(at: 9)
+            }
+            
             searchs.insert((self.searchTextField.stringValue), at: 0)
             UserDefaults.standard.set(searchs, forKey: CPDFOfficeSearchHistoryKey)