Skip to content

Create declaration/definition - handle #include edits#10219

Merged
michelleangela merged 4 commits intomainfrom
mimatias/handle-include
Dec 2, 2022
Merged

Create declaration/definition - handle #include edits#10219
michelleangela merged 4 commits intomainfrom
mimatias/handle-include

Conversation

@michelleangela
Copy link
Contributor

@michelleangela michelleangela commented Dec 2, 2022

Work item reference (GitHub issue link, etc.): none

Problem:
When create declaration definition action adds a #include "header_file" edit, the edit for the new definition gets inserted in the wrong position in a source file. The is caused by VSCode workspace.applyEdit API re-adjusting the text edit positions that was already pre-calculated by the refactoring API in the language server.

Fix:
If there is a #include "header_file" edit from create declaration definition action, adjust the position of the new definition by however many new lines the #include "header_file" may have so that VSCode workspace.applyEdit will insert it in the correct position as it calculates the position based on the first text edit.

Implementation Summary:
Get the new lines from a #include "header_file" edit and subtract that for the new definition edit starting line.

sean-mcmanus
sean-mcmanus previously approved these changes Dec 2, 2022
Copy link
Contributor

@sean-mcmanus sean-mcmanus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me. Can you fix the typo issues @jogo- found?

Also, I believe "VS Code" is the preferred spelling instead of "VSCode", i.e. it's the predominant usage.

@michelleangela michelleangela merged commit cae6c42 into main Dec 2, 2022
@michelleangela michelleangela deleted the mimatias/handle-include branch December 2, 2022 19:31
@github-actions github-actions bot locked and limited conversation to collaborators Jan 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants