Create declaration/definition - handle #include edits#10219
Merged
michelleangela merged 4 commits intomainfrom Dec 2, 2022
Merged
Create declaration/definition - handle #include edits#10219michelleangela merged 4 commits intomainfrom
#include edits#10219michelleangela merged 4 commits intomainfrom
Conversation
jogo-
reviewed
Dec 2, 2022
jogo-
reviewed
Dec 2, 2022
sean-mcmanus
previously approved these changes
Dec 2, 2022
Contributor
sean-mcmanus
left a comment
There was a problem hiding this comment.
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.
sean-mcmanus
approved these changes
Dec 2, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.