From 62c5e9d88a8e9b72b0be280f1ddad28a8789fe22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Kiss?= Date: Sun, 12 Nov 2017 15:29:30 +0100 Subject: [PATCH] fix(keymap): Handle more than 35 same keymap abbreviation (#497) --- .../src/app/store/reducers/user-configuration.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/uhk-web/src/app/store/reducers/user-configuration.ts b/packages/uhk-web/src/app/store/reducers/user-configuration.ts index 146a044f..f10b666e 100644 --- a/packages/uhk-web/src/app/store/reducers/user-configuration.ts +++ b/packages/uhk-web/src/app/store/reducers/user-configuration.ts @@ -302,6 +302,18 @@ function generateAbbr(keymaps: Keymap[], abbr: string): string { while (keymaps.some((keymap: Keymap) => keymap.abbreviation === abbr)) { abbr = abbr.substring(0, abbr.length - 1) + chars[position]; ++position; + if (position > chars.length) { + position = 0; + let firstCharIndex = chars.indexOf(abbr.substr(0, 1)); + let secondCharIndex = chars.indexOf(abbr.substr(1, 1)); + secondCharIndex++; + + if (secondCharIndex > chars.length) { + secondCharIndex = 0; + firstCharIndex++; + } + abbr = chars[firstCharIndex] + chars[secondCharIndex] + chars[position]; + } } return abbr;