diff --git a/tabby-core/src/api/index.ts b/tabby-core/src/api/index.ts index c99e16f8..4859519c 100644 --- a/tabby-core/src/api/index.ts +++ b/tabby-core/src/api/index.ts @@ -5,7 +5,7 @@ export { SplitTabComponent, SplitContainer, SplitDirection, SplitOrientation } f export { TabRecoveryProvider, RecoveryToken } from './tabRecovery' export { ToolbarButtonProvider, ToolbarButton } from './toolbarButtonProvider' export { ConfigProvider } from './configProvider' -export { HotkeyProvider, HotkeyDescription } from './hotkeyProvider' +export { HotkeyProvider, HotkeyDescription, Hotkey } from './hotkeyProvider' export { Theme } from './theme' export { TabContextMenuItemProvider } from './tabContextMenuProvider' export { SelectorOption } from './selector' diff --git a/tabby-settings/src/components/hotkeySettingsTab.component.ts b/tabby-settings/src/components/hotkeySettingsTab.component.ts index 307c37f1..06137a87 100644 --- a/tabby-settings/src/components/hotkeySettingsTab.component.ts +++ b/tabby-settings/src/components/hotkeySettingsTab.component.ts @@ -3,11 +3,12 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker' import { Component, NgZone } from '@angular/core' import { ConfigService, + Hotkey, HotkeyDescription, HotkeysService, HostAppService, } from 'tabby-core' -import { Hotkey } from 'tabby-core/src/api/hotkeyProvider' +import deepEqual from 'deep-equal' _('Search hotkeys') @@ -66,7 +67,7 @@ export class HotkeySettingsTabComponent { .flat() const isDuplicate = allHotkeys - .filter(hotkey => JSON.stringify(hotkey) === JSON.stringify(strokes)) + .filter(hotkey => deepEqual(hotkey, strokes)) .length > 1 return { strokes, isDuplicate } diff --git a/tabby-settings/src/components/multiHotkeyInput.component.ts b/tabby-settings/src/components/multiHotkeyInput.component.ts index 4bd3af12..ceefae52 100644 --- a/tabby-settings/src/components/multiHotkeyInput.component.ts +++ b/tabby-settings/src/components/multiHotkeyInput.component.ts @@ -1,7 +1,8 @@ -import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core' +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { HotkeyInputModalComponent } from './hotkeyInputModal.component' -import { Hotkey } from 'tabby-core/src/api/hotkeyProvider' +import { Hotkey } from 'tabby-core' +import deepEqual from 'deep-equal' /** @hidden */ @Component({ @@ -24,7 +25,7 @@ export class MultiHotkeyInputComponent { editItem (item: Hotkey): void { this.ngbModal.open(HotkeyInputModalComponent).result.then((newStrokes: string[]) => { - this.hotkeys.find(hotkey => this.isEqual(hotkey, item))!.strokes = newStrokes + this.hotkeys.find(hotkey => deepEqual(hotkey.strokes, item.strokes))!.strokes = newStrokes this.storeUpdatedHotkeys() }) } @@ -44,8 +45,4 @@ export class MultiHotkeyInputComponent { private storeUpdatedHotkeys () { this.hotkeysChange.emit(this.hotkeys) } - - private isEqual (h: Hotkey, item: Hotkey) { - return JSON.stringify(h.strokes) === JSON.stringify(item.strokes) - } }