diff --git a/CHANGELOG.md b/CHANGELOG.md index 32722909d..a6f51abc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. **Changed** * Sidebar lag is reduced +* More intuitive 'Go To Next/Previous Variation' * Update icons * Update to Electron v1.4.4 diff --git a/browser/index.js b/browser/index.js index f6b79a44a..86ff5cb7c 100644 --- a/browser/index.js +++ b/browser/index.js @@ -2130,14 +2130,17 @@ sabaki.goToEnd = function() { sabaki.goToSiblingVariation = function(sign) { let [tree, index] = sabaki.getCurrentTreePosition() - sign = sign < 0 ? -1 : 1 + let navigate = index == tree.nodes.length - 1 + && tree.subtrees.length > 0 + && sign > 0 + || !tree.parent - if (!tree.parent) return + sign = sign < 0 ? -1 : 1 - let mod = tree.parent.subtrees.length - let i = (tree.parent.current + mod + sign) % mod + let mod = navigate ? tree.subtrees.length : tree.parent.subtrees.length + let i = ((navigate ? tree.current : tree.parent.current) + mod + sign) % mod - sabaki.setCurrentTreePosition(tree.parent.subtrees[i], 0) + sabaki.setCurrentTreePosition(navigate ? tree.subtrees[i] : tree.parent.subtrees[i], 0) } sabaki.goToNextVariation = () => sabaki.goToSiblingVariation(1)