@@ -53,30 +53,20 @@ public static class ConsoleController
5353
5454 public static void Init ( )
5555 {
56+ // Make sure console is supported on this platform
5657 try
5758 {
5859 ResetConsole ( false ) ;
5960 // ensure the compiler is supported (if this fails then SRE is probably stubbed)
6061 Evaluator . Compile ( "0 == 0" ) ;
61-
62- if ( ! Directory . Exists ( ScriptsFolder ) )
63- Directory . CreateDirectory ( ScriptsFolder ) ;
64-
65- var startupPath = Path . Combine ( ScriptsFolder , "startup.cs" ) ;
66- if ( File . Exists ( startupPath ) )
67- {
68- ExplorerCore . Log ( $ "Executing startup script from '{ startupPath } '...") ;
69- var text = File . ReadAllText ( startupPath ) ;
70- Input . Text = text ;
71- Evaluate ( ) ;
72- }
7362 }
7463 catch ( Exception ex )
7564 {
7665 DisableConsole ( ex ) ;
7766 return ;
7867 }
7968
69+ // Setup console
8070 Lexer = new LexerBuilder ( ) ;
8171 Completer = new CSAutoCompleter ( ) ;
8272
@@ -90,6 +80,26 @@ public static void Init()
9080 Panel . OnAutoIndentToggled += OnToggleAutoIndent ;
9181 Panel . OnCtrlRToggled += OnToggleCtrlRShortcut ;
9282 Panel . OnSuggestionsToggled += OnToggleSuggestions ;
83+
84+ // Run startup script
85+ try
86+ {
87+ if ( ! Directory . Exists ( ScriptsFolder ) )
88+ Directory . CreateDirectory ( ScriptsFolder ) ;
89+
90+ var startupPath = Path . Combine ( ScriptsFolder , "startup.cs" ) ;
91+ if ( File . Exists ( startupPath ) )
92+ {
93+ ExplorerCore . Log ( $ "Executing startup script from '{ startupPath } '...") ;
94+ var text = File . ReadAllText ( startupPath ) ;
95+ Input . Text = text ;
96+ Evaluate ( ) ;
97+ }
98+ }
99+ catch ( Exception ex )
100+ {
101+ ExplorerCore . LogWarning ( $ "Exception executing startup script: { ex } ") ;
102+ }
93103 }
94104
95105
0 commit comments