[SourceKit] Map line and column using the latest snapshot

During a cursor info request, the resolved offset was mapped to line and
column using the buffer inside `SwiftDocumentSyntaxInfo`.

However, prior to 54683ca607,
`editorReplaceText` was not updating the syntax info. This meant that
snapshots would be more up to date than the buffer in the syntax info,
allowing for the possibility of an invalid offset.

While 54683ca607 would also fix this,
snapshots actually have a `getLineAndColumn` anyway. Use that instead of
grabbing the buffer from syntax info.

Resolves rdar://78161348.
This commit is contained in:
Ben Barham
2021-05-21 09:52:09 +10:00
parent 251ce36361
commit 0f21991f02
4 changed files with 12 additions and 13 deletions

View File

@@ -639,7 +639,7 @@ static void mapLocToLatestSnapshot(
}
std::tie(Location.Line, Location.Column) =
EditorDoc->getLineAndColumnInBuffer(Location.Offset);
LatestSnap->getBuffer()->getLineAndColumn(Location.Offset);
}