fix: recreating keyboardShortcuts interface on file changes. (#1465)

Co-authored-by: Aaron <aaronklinker1@gmail.com>
This commit is contained in:
Nishu
2025-06-05 11:05:13 +05:30
committed by GitHub
parent eb0bffb5dd
commit 6be9a4e71b
2 changed files with 9 additions and 7 deletions
+7 -2
View File
@@ -110,8 +110,13 @@ async function createServerInternal(): Promise<WxtDevServer> {
// Listen for file changes and reload different parts of the extension accordingly
const reloadOnChange = createFileReloader(server);
server.watcher.on('all', reloadOnChange);
keyboardShortcuts.start();
server.watcher.on('all', async (...args) => {
await reloadOnChange(args[0], args[1]);
// Restart keyboard shortcuts after file is changed - for some reason they stop working.
keyboardShortcuts.start();
});
keyboardShortcuts.printHelp({
canReopenBrowser:
!wxt.config.runnerConfig.config.disabled && !!runner.canOpen?.(),
+2 -5
View File
@@ -26,9 +26,7 @@ export function createKeyboardShortcuts(
return {
start() {
if (rl) return;
rl = readline.createInterface({
rl ??= readline.createInterface({
input: process.stdin,
terminal: false, // Don't intercept ctrl+C, ctrl+Z, etc
});
@@ -37,8 +35,7 @@ export function createKeyboardShortcuts(
},
stop() {
rl?.close();
rl = undefined;
rl?.removeListener('line', handleInput);
},
printHelp(flags) {