-
Notifications
You must be signed in to change notification settings - Fork 199
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
Unable to remap projected document edits if they fall outside of known list of source mappings #4284
Comments
Updating the issue title to better represent the underlying problem. This is more of a design limitation than a bug. Essentially, the issue is that we can't map a position/range that is not in our SourceMappings. In some cases, edits returned by Roslyn for code actions end up going to places we don't have mapping for and thus doesn't get applied. There is no easy way to get around this unless we make our mapping system more complex and make it understand more than verbatim source mappings. |
https://github.com/dotnet/aspnetcore/issues/26867 contains a targeted quick mitigation for this. The long term solution for code actions will involve heuristically determining the correct place within the razor syntax tree to insert the complete code action. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
@ajaybhargavb and I were looking into why some edits were being lost during formatting. Issue seems to be due to how we handle projections which come at the end of a document / @code block.
Passing edits into the formatter which go beyond the last line of generated C# fails. This is because the edit starts 1 line after the last source mapping, and consequently the projection mapping fails.
Call here.
Note: Code actions do not work with single line
@code
blocks as the mapping fails.Edited C# & Generated C#
Edited C#:
Original:
Another manifestation of this issue:
Invoke generate constructor code action.
Expected:
Actual:
The text was updated successfully, but these errors were encountered: