diff --git a/src/fontra/views/editor/editor.js b/src/fontra/views/editor/editor.js index 27cd7743b..56ec663db 100644 --- a/src/fontra/views/editor/editor.js +++ b/src/fontra/views/editor/editor.js @@ -42,6 +42,7 @@ import { isObjectEmpty, loadURLFragment, makeUPlusStringFromCodePoint, + modulo, parseSelection, range, readFromClipboard, @@ -2800,9 +2801,10 @@ export class EditorController { ...this.sceneSettings.glyphLocation, }); } else { - const numSources = varGlyphController.sources.length; - newSourceIndex = - (selectPrevious ? sourceIndex + numSources - 1 : sourceIndex + 1) % numSources; + newSourceIndex = modulo( + sourceIndex + (selectPrevious ? -1 : 1), + varGlyphController.sources.length + ); } this.sceneController.scrollAdjustBehavior = "pin-glyph-center"; this.sceneSettings.selectedSourceIndex = newSourceIndex;