@@ -330,17 +330,19 @@ func (s *server) DidDeleteFiles(context.Context, *protocol.DeleteFilesParams) er
330
330
func (s * server ) DidOpen (ctx context.Context , params * protocol.DidOpenTextDocumentParams ) (err error ) {
331
331
defer s .publishDiagnostics (params .TextDocument .URI )
332
332
doc := document {item : params .TextDocument }
333
- doc .ast , doc .err = jsonnet .SnippetToAST (params .TextDocument .URI .SpanURI ().Filename (), params .TextDocument .Text )
334
- if doc .err != nil {
335
- return s .cache .put (doc )
336
- }
337
- symbols := analyseSymbols (doc .ast )
338
- if len (symbols ) != 1 {
339
- panic ("There should only be a single root symbol for an AST" )
333
+ if params .TextDocument .Text != "" {
334
+ doc .ast , doc .err = jsonnet .SnippetToAST (params .TextDocument .URI .SpanURI ().Filename (), params .TextDocument .Text )
335
+ if doc .err != nil {
336
+ return s .cache .put (doc )
337
+ }
338
+ symbols := analyseSymbols (doc .ast )
339
+ if len (symbols ) != 1 {
340
+ panic ("There should only be a single root symbol for an AST" )
341
+ }
342
+ doc .symbols = symbols [0 ]
343
+ // TODO(#12): Work out better way to invalidate the VM cache.
344
+ doc .val , doc .err = s .vm .EvaluateAnonymousSnippet (params .TextDocument .URI .SpanURI ().Filename (), params .TextDocument .Text )
340
345
}
341
- doc .symbols = symbols [0 ]
342
- // TODO(#12): Work out better way to invalidate the VM cache.
343
- doc .val , doc .err = s .vm .EvaluateAnonymousSnippet (params .TextDocument .URI .SpanURI ().Filename (), params .TextDocument .Text )
344
346
return s .cache .put (doc )
345
347
}
346
348
0 commit comments