Skip to content

Commit

Permalink
Revert "Use modulo for doSelectPreviousNextSource"
Browse files Browse the repository at this point in the history
This reverts commit 987952f.
  • Loading branch information
ollimeier committed Oct 23, 2024
1 parent 987952f commit 5fb2e61
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/fontra/views/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
isObjectEmpty,
loadURLFragment,
makeUPlusStringFromCodePoint,
modulo,
parseSelection,
range,
readFromClipboard,
Expand Down Expand Up @@ -2793,18 +2792,18 @@ export class EditorController {
}
const varGlyphController =
await this.sceneModel.getSelectedVariableGlyphController();

const sourceIndex =
this.sceneSettings.selectedSourceIndex ||
varGlyphController.findNearestSourceFromSourceLocation({
const sourceIndex = this.sceneSettings.selectedSourceIndex;
let newSourceIndex;
if (sourceIndex === undefined) {
newSourceIndex = varGlyphController.findNearestSourceFromSourceLocation({
...this.sceneSettings.fontLocationSourceMapped,
...this.sceneSettings.glyphLocation,
});
const newSourceIndex = modulo(
sourceIndex + (selectPrevious ? -1 : 1),
varGlyphController.sources.length
);

} else {
const numSources = varGlyphController.sources.length;
newSourceIndex =
(selectPrevious ? sourceIndex + numSources - 1 : sourceIndex + 1) % numSources;
}
this.sceneController.scrollAdjustBehavior = "pin-glyph-center";
this.sceneSettings.selectedSourceIndex = newSourceIndex;
}
Expand Down

0 comments on commit 5fb2e61

Please sign in to comment.