Skip to content

Commit c669ce0

Browse files
authored
fix:(lsp) cache textDocument/definition (#31)
1 parent ff4cf80 commit c669ce0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lang/lsp/lsp.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ func (cli *LSPClient) SemanticTokens(ctx context.Context, id Location) ([]Token,
356356

357357
var resp SemanticTokens
358358
if err := cli.getSemanticTokensRange(ctx, req, &resp, cli.Language == uniast.Cxx); err != nil {
359-
360359
return nil, err
361360
}
362361

@@ -373,6 +372,11 @@ func (cli *LSPClient) Definition(ctx context.Context, uri DocumentURI, pos Posit
373372
if err != nil {
374373
return nil, err
375374
}
375+
if f.Definitions != nil {
376+
if locations, ok := f.Definitions[pos]; ok {
377+
return locations, nil
378+
}
379+
}
376380

377381
// call
378382
req := lsp.TextDocumentPositionParams{
@@ -385,6 +389,7 @@ func (cli *LSPClient) Definition(ctx context.Context, uri DocumentURI, pos Posit
385389
if err := cli.Call(ctx, "textDocument/definition", req, &resp); err != nil {
386390
return nil, err
387391
}
392+
388393
// cache definitions
389394
if f.Definitions == nil {
390395
f.Definitions = make(map[Position][]Location)

0 commit comments

Comments
 (0)