Skip to content

Commit

Permalink
'#1866: Fix modulo to avoid negative offsets.
Browse files Browse the repository at this point in the history
  • Loading branch information
wladimirleite committed Sep 13, 2023
1 parent e164667 commit 626040e
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ public static Color getInitialColor(Set<Color> usedColors, String name) {
if (colorsMemo.containsKey(key)) {
return colorsMemo.get(key);
}
int off = key % BookmarkStandardColors.numStandardColors;
int num = BookmarkStandardColors.numStandardColors;
int off = (key % num + num) % num;
Color ret = BookmarkStandardColors.colors[off];
for (int i = 0; i < BookmarkStandardColors.numStandardColors; i++) {
int idx = (off + i) % BookmarkStandardColors.numStandardColors;
for (int i = 0; i < num; i++) {
int idx = (off + i) % num;
Color c = BookmarkStandardColors.colors[idx];
if (!usedColors.contains(c)) {
ret = c;
Expand Down

0 comments on commit 626040e

Please sign in to comment.