Skip to content

Commit 3db0198

Browse files
ert78gbmondalaci
authored andcommitted
feat(keymap): Keymap abbr should be only number or ASCII char (#360)
* feat(keymap): Keymap abbr should be only number or ASCII char close #341 * fix(keymap): Allow '1' when generate keymap abbreviation
1 parent c1f96ae commit 3db0198

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

shared/src/components/keymap/header/keymap-header.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export class KeymapHeaderComponent implements OnChanges {
7272
}
7373

7474
editKeymapAbbr(newAbbr: string) {
75-
if (newAbbr.length !== 3) {
75+
const regexp = new RegExp(/^[a-zA-Z\d]+$/g);
76+
77+
if (newAbbr.length < 1 || newAbbr.length > 3 || !regexp.test(newAbbr)) {
7678
this.renderer.setElementProperty(this.keymapAbbr.nativeElement, 'value', this.keymap.abbreviation);
7779
return;
7880
}

shared/src/store/reducers/user-configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export function getMacro(id: number) {
274274
}
275275

276276
function generateAbbr(keymaps: Keymap[], abbr: string): string {
277-
const chars: string[] = '23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
277+
const chars: string[] = '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
278278
let position = 0;
279279

280280
while (keymaps.some((keymap: Keymap) => keymap.abbreviation === abbr)) {

0 commit comments

Comments
 (0)