@@ -12,6 +12,26 @@ import { log } from './util';
12
12
let ctx : Ctx | undefined ;
13
13
14
14
export async function activate ( context : vscode . ExtensionContext ) {
15
+ // Register a "dumb" onEnter command for the case where server fails to
16
+ // start.
17
+ //
18
+ // FIXME: refactor command registration code such that commands are
19
+ // **always** registered, even if the server does not start. Use API like
20
+ // this perhaps?
21
+ //
22
+ // ```TypeScript
23
+ // registerCommand(
24
+ // factory: (Ctx) => ((Ctx) => any),
25
+ // fallback: () => any = () => vscode.window.showErrorMessage(
26
+ // "rust-analyzer is not available"
27
+ // ),
28
+ // )
29
+ const defaultOnEnter = vscode . commands . registerCommand (
30
+ 'rust-analyzer.onEnter' ,
31
+ ( ) => vscode . commands . executeCommand ( 'default:type' , { text : '\n' } ) ,
32
+ ) ;
33
+ context . subscriptions . push ( defaultOnEnter ) ;
34
+
15
35
const config = new Config ( context ) ;
16
36
17
37
const serverPath = await ensureServerBinary ( config . serverSource ) ;
@@ -54,7 +74,10 @@ export async function activate(context: vscode.ExtensionContext) {
54
74
ctx . registerCommand ( 'syntaxTree' , commands . syntaxTree ) ;
55
75
ctx . registerCommand ( 'expandMacro' , commands . expandMacro ) ;
56
76
ctx . registerCommand ( 'run' , commands . run ) ;
77
+
78
+ defaultOnEnter . dispose ( ) ;
57
79
ctx . registerCommand ( 'onEnter' , commands . onEnter ) ;
80
+
58
81
ctx . registerCommand ( 'ssr' , commands . ssr ) ;
59
82
ctx . registerCommand ( 'serverVersion' , commands . serverVersion ) ;
60
83
0 commit comments