Skip to content

Support cursor info-based requests when cursor is placed at the end of an identifier #975

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
Nov 27, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Nov 23, 2023

VS Code considers the position after an identifier as part of an identifier. Ie. if you have let foo| = 1, then it considers the cursor to be positioned at the identifier. This scenario is hit, when selecting an identifier by double-clicking it and then eg. performing jump-to-definition. In that case VS Code will send the position after the identifier. sourcekitd, on the other hand, does not consider the position after the identifier as part of the identifier. To bridge the gap here, normalize any positions inside, or directly after, an identifier to the identifier's start.

Fixes #820
rdar://115557453

@ahoppen ahoppen requested a review from benlangmuir as a code owner November 23, 2023 02:56
@ahoppen ahoppen force-pushed the ahoppen/normalize-identifier-start branch from 52c7749 to 42c2b12 Compare November 23, 2023 03:07
@ahoppen ahoppen force-pushed the ahoppen/normalize-identifier-start branch 2 times, most recently from e3d6c09 to c5c8614 Compare November 24, 2023 01:54
…f an identifier

VS Code considers the position after an identifier as part of an identifier. Ie. if you have `let foo| = 1`, then it considers the cursor to be positioned at the identifier. This scenario is hit, when selecting an identifier by double-clicking it and then eg. performing jump-to-definition. In that case VS Code will send the position after the identifier.
`sourcekitd`, on the other hand, does not consider the position after the identifier as part of the identifier.
To bridge the gap here, normalize any positions inside, or directly after, an identifier to the identifier's start.

Fixes swiftlang#820
rdar://115557453
@ahoppen ahoppen force-pushed the ahoppen/normalize-identifier-start branch from c5c8614 to f5e26e4 Compare November 24, 2023 04:22
@ahoppen
Copy link
Member Author

ahoppen commented Nov 24, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Nov 27, 2023

@swift-ci Please test Windows

@ahoppen ahoppen merged commit e6cf723 into swiftlang:main Nov 27, 2023
@ahoppen ahoppen deleted the ahoppen/normalize-identifier-start branch November 27, 2023 23:36
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.

Cursor position at end of symbol, doesn't capture symbol
2 participants