瀏覽代碼

[notebook] Maintain order in snippet wheel when adding snippets from history

Johan Ahlen 10 年之前
父節點
當前提交
95ee5eb
共有 1 個文件被更改,包括 5 次插入6 次删除
  1. 5 6
      desktop/core/src/desktop/templates/ko_components.mako

+ 5 - 6
desktop/core/src/desktop/templates/ko_components.mako

@@ -1002,13 +1002,12 @@ from desktop.views import _ko
             return;
           }
 
-          var currentIndex = self.snippetHistory().indexOf(alternative);
-          if (currentIndex > -1) {
-            self.snippetHistory().splice(currentIndex, 1);
-          } else if (self.snippetHistory().length == 5) {
-            self.snippetHistory.pop();
+          if (self.snippetHistory().indexOf(alternative) == -1) {
+            if (self.snippetHistory().length == 5) {
+              self.snippetHistory.pop();
+            }
+            self.snippetHistory.unshift(alternative);
           }
-          self.snippetHistory.unshift(alternative);
 
           self.notebook.newSnippet(alternative.type())
         };