1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-30 02:54:04 +03:00

fixed hotkey IDs for profiles with "." in name - fixes #4367

This commit is contained in:
Eugene Pankov 2021-08-07 19:35:11 +02:00
parent 9fbf9136fc
commit dfdb3b051b
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
2 changed files with 9 additions and 3 deletions

View File

@ -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<Profile>): string {
return profile.id!.replace(/\./g, '-')
}
}

View File

@ -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)
}