@@ -12,6 +12,26 @@ import { log } from './util';
1212let ctx : Ctx | undefined ;
1313
1414export 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+
1535 const config = new Config ( context ) ;
1636
1737 const serverPath = await ensureServerBinary ( config . serverSource ) ;
@@ -54,7 +74,10 @@ export async function activate(context: vscode.ExtensionContext) {
5474 ctx . registerCommand ( 'syntaxTree' , commands . syntaxTree ) ;
5575 ctx . registerCommand ( 'expandMacro' , commands . expandMacro ) ;
5676 ctx . registerCommand ( 'run' , commands . run ) ;
77+
78+ defaultOnEnter . dispose ( ) ;
5779 ctx . registerCommand ( 'onEnter' , commands . onEnter ) ;
80+
5881 ctx . registerCommand ( 'ssr' , commands . ssr ) ;
5982 ctx . registerCommand ( 'serverVersion' , commands . serverVersion ) ;
6083
0 commit comments