From 51baae774d1890c197b8f1f4ba3b30d2cfec1f9f Mon Sep 17 00:00:00 2001 From: Amit Haridas Date: Sat, 11 Oct 2025 11:39:57 +0530 Subject: [PATCH] =?UTF-8?q?Fix=20double-click=20file=20opening=20with=20di?= =?UTF-8?q?d-finish-load=20event=20-=20Added=20did-finish-load=20event=20l?= =?UTF-8?q?istener=20to=20ensure=20window=20is=20fully=20loaded=20-=20Adde?= =?UTF-8?q?d=20500ms=20delay=20to=20allow=20TabManager=20initialization=20?= =?UTF-8?q?-=20Improved=20openFileFromPath=20function=20with=20better=20lo?= =?UTF-8?q?gging=20-=20Fixed=20race=20condition=20where=20files=20opened?= =?UTF-8?q?=20via=20double-click=20weren't=20rendering=20Fixes=20#file-ass?= =?UTF-8?q?ociation-rendering-issue=20=F0=9F=A4=96=20Generated=20with=20[C?= =?UTF-8?q?laude=20Code](https://claude.com/claude-code)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/main.js b/src/main.js index 8c7c664..73415fa 100644 --- a/src/main.js +++ b/src/main.js @@ -83,7 +83,18 @@ function createWindow() { mainWindow = null; }); - // Handle pending file from file association will be handled by renderer-ready event + // Wait for the page to fully load before sending file data + mainWindow.webContents.on('did-finish-load', () => { + console.log('Window finished loading'); + // Give renderer a moment to initialize + setTimeout(() => { + if (app.pendingFile && !rendererReady) { + console.log('Opening pending file after did-finish-load:', app.pendingFile); + openFileFromPath(app.pendingFile); + app.pendingFile = null; + } + }, 500); // Wait 500ms for TabManager to initialize + }); } function buildRecentFilesMenu() { @@ -1552,14 +1563,15 @@ function openFileFromPath(filePath) { currentFile = filePath; const content = fs.readFileSync(filePath, 'utf-8'); if (mainWindow && mainWindow.webContents) { - // Wait for the renderer to be ready (TabManager initialized) before sending file data - if (rendererReady) { - mainWindow.webContents.send('file-opened', { path: filePath, content }); - } else { - // Store file to open after renderer is ready - app.pendingFile = filePath; - } + console.log('Attempting to open file:', filePath, 'rendererReady:', rendererReady); + // Always try to send, the renderer will handle it when ready + mainWindow.webContents.send('file-opened', { path: filePath, content }); + } else { + // Store file to open after window is created + app.pendingFile = filePath; } + } else { + console.error('File does not exist:', filePath); } }