Skip to content

Commit 7e3e534

Browse files
authored
fix: fix crash when open non-ts files (#295)
1 parent b22bf35 commit 7e3e534

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

internal/lsp/service.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,21 @@ func (s *Server) handleDocumentDiagnostic(ctx context.Context, params *lsproto.D
215215
uriString := string(params.TextDocument.Uri)
216216
uri := params.TextDocument.Uri
217217
content := s.documents[uri]
218+
// Collect diagnostics
219+
var lsp_diagnostics []*lsproto.Diagnostic
218220

219221
// Only process TypeScript/JavaScript files
220222
if !isTypeScriptFile(uriString) {
221-
return lsproto.DocumentDiagnosticResponse{}, nil
223+
return lsproto.RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport{
224+
FullDocumentDiagnosticReport: &lsproto.RelatedFullDocumentDiagnosticReport{
225+
Items: lsp_diagnostics,
226+
},
227+
}, nil
222228
}
223229

224230
// Initialize rule registry with all available rules (ensure it's done once)
225231
config.RegisterAllRules()
226232

227-
// Collect diagnostics
228-
var lsp_diagnostics []*lsproto.Diagnostic
229-
230233
rule_diags, err := runLintWithProjectService(uri, s.projectService, ctx, s.rslintConfig)
231234

232235
if err != nil {

0 commit comments

Comments
 (0)