From ed80fba4c9c3b7f48914ee9ead191b013c196aa8 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sat, 18 Nov 2023 11:03:10 +0800 Subject: [PATCH] feat: hotkey scopeStack --- src/core/main/custom/hotkey.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/main/custom/hotkey.ts b/src/core/main/custom/hotkey.ts index 462c665..8e24766 100644 --- a/src/core/main/custom/hotkey.ts +++ b/src/core/main/custom/hotkey.ts @@ -34,6 +34,7 @@ export class Hotkey extends EventEmitter { keyMap: Map = new Map(); private scope: symbol = Symbol(); + private scopeStack: symbol[] = []; constructor(id: string, name: string) { super(); @@ -80,6 +81,7 @@ export class Hotkey extends EventEmitter { * @param symbol 当前作用域的symbol */ use(symbol: symbol) { + this.scopeStack.push(symbol); this.scope = symbol; for (const key of Object.values(this.data)) { key.func.set(symbol, () => {}); @@ -94,6 +96,7 @@ export class Hotkey extends EventEmitter { for (const key of Object.values(this.data)) { key.func.delete(symbol); } + this.scope = this.scopeStack.pop() ?? Symbol(); } /**