@@ -30,14 +30,14 @@ import { TheiaBrowserWindowOptions } from '@theia/core/lib/electron-main/theia-e
30
30
app . commandLine . appendSwitch ( 'disable-http-cache' ) ;
31
31
32
32
interface WorkspaceOptions {
33
- file : string
34
- x : number
35
- y : number
36
- width : number
37
- height : number
38
- isMaximized : boolean
39
- isFullScreen : boolean
40
- time : number
33
+ file : string ;
34
+ x : number ;
35
+ y : number ;
36
+ width : number ;
37
+ height : number ;
38
+ isMaximized : boolean ;
39
+ isFullScreen : boolean ;
40
+ time : number ;
41
41
}
42
42
43
43
const WORKSPACES = 'workspaces' ;
@@ -147,7 +147,7 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
147
147
if ( os . isOSX ) {
148
148
app . on ( 'open-file' , async ( event , uri ) => {
149
149
event . preventDefault ( ) ;
150
- if ( uri . endsWith ( '.ino' ) && await fs . pathExists ( uri ) ) {
150
+ if ( uri . endsWith ( '.ino' ) && ( await fs . pathExists ( uri ) ) ) {
151
151
this . openFilePromise . reject ( ) ;
152
152
await this . openSketch ( dirname ( uri ) ) ;
153
153
}
@@ -159,10 +159,12 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
159
159
}
160
160
161
161
protected async isValidSketchPath ( uri : string ) : Promise < boolean | undefined > {
162
- return typeof uri === 'string' && await fs . pathExists ( uri ) ;
162
+ return typeof uri === 'string' && ( await fs . pathExists ( uri ) ) ;
163
163
}
164
164
165
- protected override async launch ( params : ElectronMainExecutionParams ) : Promise < void > {
165
+ protected override async launch (
166
+ params : ElectronMainExecutionParams
167
+ ) : Promise < void > {
166
168
try {
167
169
// When running on MacOS, we either have to wait until
168
170
// 1. The `open-file` command has been received by the app, rejecting the promise
@@ -173,13 +175,14 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
173
175
return ;
174
176
}
175
177
176
- if ( ! os . isOSX && await this . launchFromArgs ( params ) ) {
178
+ if ( ! os . isOSX && ( await this . launchFromArgs ( params ) ) ) {
177
179
// Application has received a file in its arguments and will skip the default application launch
178
180
return ;
179
181
}
180
182
181
183
this . startup = true ;
182
- const workspaces : WorkspaceOptions [ ] | undefined = this . electronStore . get ( WORKSPACES ) ;
184
+ const workspaces : WorkspaceOptions [ ] | undefined =
185
+ this . electronStore . get ( WORKSPACES ) ;
183
186
let useDefault = true ;
184
187
if ( workspaces && workspaces . length > 0 ) {
185
188
console . log (
@@ -198,12 +201,17 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
198
201
}
199
202
}
200
203
201
- protected async launchFromArgs ( params : ElectronMainExecutionParams ) : Promise < boolean > {
204
+ protected async launchFromArgs (
205
+ params : ElectronMainExecutionParams
206
+ ) : Promise < boolean > {
202
207
// Copy to prevent manipulation of original array
203
208
const argCopy = [ ...params . argv ] ;
204
209
let uri : string | undefined ;
205
210
for ( const possibleUri of argCopy ) {
206
- if ( possibleUri . endsWith ( '.ino' ) && await this . isValidSketchPath ( possibleUri ) ) {
211
+ if (
212
+ possibleUri . endsWith ( '.ino' ) &&
213
+ ( await this . isValidSketchPath ( possibleUri ) )
214
+ ) {
207
215
uri = possibleUri ;
208
216
break ;
209
217
}
@@ -215,7 +223,9 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
215
223
return false ;
216
224
}
217
225
218
- protected async openSketch ( workspace : WorkspaceOptions | string ) : Promise < BrowserWindow > {
226
+ protected async openSketch (
227
+ workspace : WorkspaceOptions | string
228
+ ) : Promise < BrowserWindow > {
219
229
const options = await this . getLastWindowOptions ( ) ;
220
230
let file : string ;
221
231
if ( typeof workspace === 'object' ) {
@@ -229,19 +239,26 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
229
239
} else {
230
240
file = workspace ;
231
241
}
232
- const [ uri , electronWindow ] = await Promise . all ( [ this . createWindowUri ( ) , this . createWindow ( options ) ] ) ;
242
+ const [ uri , electronWindow ] = await Promise . all ( [
243
+ this . createWindowUri ( ) ,
244
+ this . createWindow ( options ) ,
245
+ ] ) ;
233
246
electronWindow . loadURL ( uri . withFragment ( encodeURI ( file ) ) . toString ( true ) ) ;
234
247
return electronWindow ;
235
248
}
236
249
237
- protected override avoidOverlap ( options : TheiaBrowserWindowOptions ) : TheiaBrowserWindowOptions {
250
+ protected override avoidOverlap (
251
+ options : TheiaBrowserWindowOptions
252
+ ) : TheiaBrowserWindowOptions {
238
253
if ( this . startup ) {
239
254
return options ;
240
255
}
241
256
return super . avoidOverlap ( options ) ;
242
257
}
243
258
244
- protected override getTitleBarStyle ( config : FrontendApplicationConfig ) : 'native' | 'custom' {
259
+ protected override getTitleBarStyle (
260
+ config : FrontendApplicationConfig
261
+ ) : 'native' | 'custom' {
245
262
return 'native' ;
246
263
}
247
264
@@ -255,8 +272,15 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
255
272
} ) ;
256
273
}
257
274
258
- protected override async onSecondInstance ( event : ElectronEvent , argv : string [ ] , cwd : string ) : Promise < void > {
259
- if ( ! os . isOSX && await this . launchFromArgs ( { cwd, argv, secondInstance : true } ) ) {
275
+ protected override async onSecondInstance (
276
+ event : ElectronEvent ,
277
+ argv : string [ ] ,
278
+ cwd : string
279
+ ) : Promise < void > {
280
+ if (
281
+ ! os . isOSX &&
282
+ ( await this . launchFromArgs ( { cwd, argv, secondInstance : true } ) )
283
+ ) {
260
284
// Application has received a file in its arguments
261
285
return ;
262
286
}
@@ -268,7 +292,7 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
268
292
*
269
293
* @param options
270
294
*/
271
- override async createWindow (
295
+ override async createWindow (
272
296
asyncOptions : MaybePromise < TheiaBrowserWindowOptions > = this . getDefaultTheiaWindowOptions ( )
273
297
) : Promise < BrowserWindow > {
274
298
let options = await asyncOptions ;
@@ -339,6 +363,9 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
339
363
options . webPreferences = { } ;
340
364
}
341
365
options . webPreferences . v8CacheOptions = 'bypassHeatCheck' ; // TODO: verify this. VS Code use this V8 option.
366
+ options . useContentSize = true ;
367
+ options . minWidth = 680 ;
368
+ options . minHeight = 565 ;
342
369
return options ;
343
370
}
344
371
@@ -456,8 +483,8 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
456
483
isMaximized : window . isMaximized ( ) ,
457
484
isFullScreen : window . isFullScreen ( ) ,
458
485
file : workspaceUri . fsPath ,
459
- time : now
460
- } )
486
+ time : now ,
487
+ } ) ;
461
488
}
462
489
} ) ;
463
490
}
0 commit comments