From dfdb3b051baa763b236c0a111e0fcbab62beaf5c Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 7 Aug 2021 19:35:11 +0200 Subject: [PATCH] fixed hotkey IDs for profiles with "." in name - fixes #4367 --- tabby-core/src/hotkeys.ts | 7 ++++++- tabby-core/src/index.ts | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tabby-core/src/hotkeys.ts b/tabby-core/src/hotkeys.ts index 22efc28a..42562936 100644 --- a/tabby-core/src/hotkeys.ts +++ b/tabby-core/src/hotkeys.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core' import { ProfilesService } from './services/profiles.service' import { HotkeyDescription, HotkeyProvider } from './api/hotkeyProvider' +import { PartialProfile, Profile } from './api' /** @hidden */ @Injectable() @@ -193,9 +194,13 @@ export class AppHotkeyProvider extends HotkeyProvider { return [ ...this.hotkeys, ...profiles.map(profile => ({ - id: `profile.${profile.id}`, + id: `profile.${AppHotkeyProvider.getProfileHotkeyName(profile)}`, name: `New tab: ${profile.name}`, })), ] } + + static getProfileHotkeyName (profile: PartialProfile): string { + return profile.id!.replace(/\./g, '-') + } } diff --git a/tabby-core/src/index.ts b/tabby-core/src/index.ts index ea1a388c..296eb8f8 100644 --- a/tabby-core/src/index.ts +++ b/tabby-core/src/index.ts @@ -151,8 +151,9 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex hotkeys.hotkey$.subscribe(async (hotkey) => { if (hotkey.startsWith('profile.')) { - const id = hotkey.split('.')[1] - const profile = (await profilesService.getProfiles()).find(x => x.id === id) + const id = hotkey.substring(hotkey.indexOf('.') + 1) + const profiles = await profilesService.getProfiles() + const profile = profiles.find(x => AppHotkeyProvider.getProfileHotkeyName(x) === id) if (profile) { profilesService.openNewTabForProfile(profile) }