Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix issue in watch window completion #77204

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ToddGrun
Copy link
Contributor

The issue here is when the watch window contains

for (int i = 0; i < 10; i++)
[Console.WriteLine(i);]

where [] denotes the current statement. In that case, the adjusted context should be at the start of Console.WriteLine. Additionally, a semicolon should not be placed in the generated projection buffer before debuggerMappedSpan, as that would place debuggerMappedSpan outside the for loop.

Fixes #42718

The issue here is when the watch window contains

for (int i = 0; i < 10; i++)
    [Console.WriteLine(i);]

where [] denotes the current statement. In that case, the adjusted context should be at the start of Console.WriteLine. Additionally, a semicolon should not be placed in the generated projection buffer before debuggerMappedSpan, as that would place debuggerMappedSpan outside the for loop.

Fixes dotnet#42718
@ToddGrun ToddGrun requested a review from a team as a code owner February 13, 2025 15:21
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 13, 2025
@ToddGrun ToddGrun requested a review from genlu February 13, 2025 15:21
@@ -152,21 +148,10 @@ private bool TrySetContext(
regionEdit.Apply();
}

// Adjust the context point to ensure that the right information is in scope.
// For example, we may need to move the point to the end of the last statement in a method body
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comment is not true, and led me astray for quite a while.

var contextPoint = this.ContextBuffer.CurrentSnapshot.GetLineFromLineNumber(CurrentStatementSpan.iEndLine).Start + CurrentStatementSpan.iEndIndex;
var adjustedContextPoint = GetAdjustedContextPoint(contextPoint, document);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found having multiple abstract methods made this more confusing, and I needed to add in another concept which would have made this worse. Instead, just a single abstract method that just returns the end projection buffer and let the language implementations stitch them together themselves.

@ToddGrun
Copy link
Contributor Author

@genlu or @jasonmalinowski -- as the bug mentions, this area is magic, but I think I found an incantation to make this scenario work.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IntelliSense doesn't work in watch window
1 participant