Update main.js

This commit is contained in:
Anirudh Sevugan 2025-02-27 23:57:48 +05:30 committed by GitHub
parent daead7a5f7
commit 770a7684da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -210,6 +210,16 @@ app.whenReady().then(() => {
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
// ✅ Windows: Handle file reopening while app is already running
if (!app.requestSingleInstanceLock()) {
app.quit();
} else {
app.on("second-instance", (event, argv) => {
const fileArg = argv.find(arg => arg.startsWith("C:\\") || arg.startsWith("/"));
if (fileArg) openFileSafely(fileArg);
});
}
});
let hasOpenedFile = false;