@@ -23,9 +23,40 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
2323 // See: https://github.com/electron-userland/electron-builder/issues/2468
2424 // Regression in Theia: https://github.com/eclipse-theia/theia/issues/8701
2525 app . on ( 'ready' , ( ) => app . setName ( config . applicationName ) ) ;
26+
27+ // Add file associations to the app
28+ this . attachFileAssociations ( ) ;
29+
2630 return super . start ( config ) ;
2731 }
2832
33+ attachFileAssociations ( ) {
34+
35+ // OSX: register open-file event
36+ if ( process . platform === 'darwin' ) {
37+ app . on ( 'open-file' , ( event , uri ) => {
38+ event . preventDefault ( ) ;
39+ // TODO: check if the URI is a .ino file
40+ // should I call openSketchFiles(uri) ?
41+ } ) ;
42+ }
43+
44+ // WIN: read file(s) uri from executable args
45+ if ( process . platform === 'win32' ) {
46+ if ( app . isPackaged ) {
47+ // workaround for missing executable argument when app is packaged
48+ process . argv . unshift ( 'packaged' ) ;
49+ }
50+ // parameters is an array containing any files/folders that your OS will pass to your application
51+ const uri = process . argv . slice ( 2 ) || null ;
52+ if ( uri ) {
53+ // TODO: filter out only the first .ino file in the array
54+ // should I call openSketchFiles(uri) ?
55+ }
56+ }
57+
58+ }
59+
2960 /**
3061 * Use this rather than creating `BrowserWindow` instances from scratch, since some security parameters need to be set, this method will do it.
3162 *
0 commit comments