mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 20:11:54 +00:00
fix: Don't propagate un-translated source ranges (#64263)
The `getSourceRange` function can have a range translation failure, in which case it would be wrong to propagate the range directly without the commit information. So skip the ranges in that case.
This commit is contained in:
parent
ef77a1e0e1
commit
7595615f07
@ -107,7 +107,7 @@ func (s *Service) GetHover(ctx context.Context, args PositionalRequestArgs, requ
|
||||
}
|
||||
|
||||
// Adjust the highlighted range back to the appropriate range in the target commit
|
||||
_, adjustedRange, _, err := s.getSourceRange(ctx,
|
||||
_, adjustedRange, success, err := s.getSourceRange(ctx,
|
||||
args.RequestArgs, requestState,
|
||||
cachedUploads[i].RepositoryID, cachedUploads[i].Commit,
|
||||
args.Path, rn)
|
||||
@ -118,8 +118,10 @@ func (s *Service) GetHover(ctx context.Context, args PositionalRequestArgs, requ
|
||||
// Text attached to source range
|
||||
return text, adjustedRange, true, nil
|
||||
}
|
||||
if success {
|
||||
adjustedRanges = append(adjustedRanges, adjustedRange)
|
||||
|
||||
adjustedRanges = append(adjustedRanges, adjustedRange)
|
||||
}
|
||||
}
|
||||
|
||||
// The Slow path:
|
||||
@ -632,12 +634,13 @@ func (s *Service) GetStencil(ctx context.Context, args PositionalRequestArgs, re
|
||||
// FIXME: change this at it expects an empty uploadsshared.CompletedUpload{}
|
||||
cu := requestState.GetCacheUploadsAtIndex(i)
|
||||
// Adjust the highlighted range back to the appropriate range in the target commit
|
||||
_, adjustedRange, _, err := s.getSourceRange(ctx, args.RequestArgs, requestState, cu.RepositoryID, cu.Commit, args.Path, rn)
|
||||
_, adjustedRange, success, err := s.getSourceRange(ctx, args.RequestArgs, requestState, cu.RepositoryID, cu.Commit, args.Path, rn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
adjustedRanges = append(adjustedRanges, adjustedRange)
|
||||
if success {
|
||||
adjustedRanges = append(adjustedRanges, adjustedRange)
|
||||
}
|
||||
}
|
||||
}
|
||||
trace.AddEvent("TODO Domain Owner", attribute.Int("numRanges", len(adjustedRanges)))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user