Skip to content

[SourceKit] Map line and column using the latest snapshot #37547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2021

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented May 21, 2021

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

However, prior to 54683ca,
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 54683ca would also fix this,
snapshots actually have a getLineAndColumn anyway. Use that instead of
grabbing the buffer from syntax info.

Resolves rdar://78161348.

@bnbarham bnbarham requested review from akyrtzi and benlangmuir May 21, 2021 00:55
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - fb6a2c57d8304771bdcacba5b32ff8ccabb9dfbc

@bnbarham
Copy link
Contributor Author

PR to disable those tests is now merged.

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - fb6a2c57d8304771bdcacba5b32ff8ccabb9dfbc

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

However, prior to 54683ca,
`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 54683ca would also fix this,
snapshots actually have a `getLineAndColumn` anyway. Use that instead of
grabbing the buffer from syntax info.

Resolves rdar://78161348.
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0f21991

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 0f21991

@akyrtzi
Copy link
Contributor

akyrtzi commented May 21, 2021

Unrelated failures:

Failed Tests (2):
  Swift(macosx-x86_64) :: Distributed/distributed_actor_is_experimental.swift
  Swift(macosx-x86_64) :: Distributed/distributed_actor_isolation.swift

@akyrtzi akyrtzi merged commit 53264a6 into swiftlang:main May 21, 2021
@bnbarham bnbarham deleted the line-col-crash branch May 21, 2021 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants