-
Notifications
You must be signed in to change notification settings - Fork 77
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-1483 Implement apply fix suggestion #5726
Changes from 1 commit
2f463d0
3679763
afd98a4
a8b68d0
4934958
7f00766
dc99c04
4dae51e
6f62921
186552c
78973a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,23 +95,28 @@ private void ApplySuggestedChanges(string absoluteFilePath, List<ChangesDto> cha | |
{ | ||
ideWindowService.BringToFront(); | ||
var textView = documentNavigator.Open(absoluteFilePath); | ||
var textEdit = textView.TextBuffer.CreateEdit(); | ||
for (var i = changes.Count - 1; i >= 0; i--) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because it is in descending order, the last change that is visible is actually the first change. Do you think it makes sense? Or should the last change be the visible one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There were two considerations behind this decision:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand 1. But I don't think we can really judge that 2 is something that will always happen (it might be that the first change is removing a line). Anyway, we can leave it like this and see the feedback from users. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same behavior applies to SLI, it focuses on the first change. |
||
{ | ||
var changeDto = changes[i]; | ||
var textEdit = textView.TextBuffer.CreateEdit(); | ||
|
||
try | ||
{ | ||
var spanToUpdate = issueSpanCalculator.CalculateSpan(textView.TextSnapshot, changeDto.beforeLineRange.startLine, changeDto.beforeLineRange.endLine); | ||
textView.Caret.MoveTo(spanToUpdate.Start); | ||
textView.ViewScroller.EnsureSpanVisible(spanToUpdate, EnsureSpanVisibleOptions.AlwaysCenter); | ||
if (i == 0) | ||
{ | ||
textView.Caret.MoveTo(spanToUpdate.Start); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider extracting the lines 106-110 into a separate method. Clean code usually recommends to avoid having huge methods as this crowds the logic and makes it more difficult to understand. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this particular case, I think that it's better not to extract the if to a separate method. If I had to move something for clarity I would consider reworking the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will there be a coming back to the refactoring, though? There is no task for it... |
||
textView.ViewScroller.EnsureSpanVisible(spanToUpdate, EnsureSpanVisibleOptions.AlwaysCenter); | ||
} | ||
textEdit.Replace(spanToUpdate, changeDto.after); | ||
textEdit.Apply(); | ||
} | ||
catch (Exception) | ||
{ | ||
textEdit.Cancel(); | ||
throw; | ||
} | ||
} | ||
|
||
textEdit.Apply(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it should also be Received(1).EnsureSpanVisible to ensure it is received once and not any amount of times (Received() will not check for the amount of times it is called)