Skip to content
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

SLVS-1746 Change logic so that the diff view window shows all suggested changes that are selectable #5966

Conversation

gabriela-trutan-sonarsource
Copy link
Contributor

@gabriela-trutan-sonarsource gabriela-trutan-sonarsource commented Jan 27, 2025

SLVS-1746

Show all suggested changes in the same window, where the user can select/unselect the desired changes

The logic has also changed a bit: before my changes, if the file was changed and we could not have an exact match between how the text looks on the machine and what we receive from server that it looked like before, we were showing a goldbar. Now we don't show the goldbar and proceed with the diff view. This behavior is also consistent with the one from Vs Code and IntelliJ.

public void ApplySuggestedChanges()
{
Before = textViewEditor.CreateTextBuffer(TextBuffer.CurrentSnapshot.GetText(), TextBuffer.ContentType);
After = textViewEditor.CreateTextBuffer(TextBuffer.CurrentSnapshot.GetText(), TextBuffer.ContentType);

Choose a reason for hiding this comment

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

Can we combine create with preview changes below? Aka CreateUpdatedBuffer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? I think the responsibilities are much clearer this way

{
try
{
var line = textView.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNumber);

Choose a reason for hiding this comment

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

DocumentNavigator.Navigate could be reused here. WDYT?

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 would need the SnapshotSpan, which I don't have at this point.

Choose a reason for hiding this comment

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

They're calculated in ApplyChanges in the same class, could cache them probably

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 wouldn't do that. I don't see the advantages

///// The changes are applied from bottom to top to avoid changing the line numbers
///// of the changes that are below the current change.
///// This is important when the change is more lines than the original line range.
///// </summary>

Choose a reason for hiding this comment

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

could create tracking spans for original locations to avoid that?

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 is not a logic that I introduced. I moved it away from the FixSuggestionHandler. If you think it's worth improving that, consider creating another task.

Copy link
Contributor

Choose a reason for hiding this comment

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

A few questions/proposals, but overall is fine

@gabriela-trutan-sonarsource gabriela-trutan-sonarsource merged commit e2bb0cb into feature/fix-suggestion-diff Jan 28, 2025
3 checks passed
@gabriela-trutan-sonarsource gabriela-trutan-sonarsource deleted the gt/diff-view-integrated-wnd branch January 28, 2025 15:55
georgii-borovinskikh-sonarsource pushed a commit that referenced this pull request Jan 31, 2025
gabriela-trutan-sonarsource added a commit that referenced this pull request Feb 3, 2025
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.

2 participants