Skip to content

Commit 7436fc6

Browse files
committed
Merge pull request #1261 from retailcoder/next
Fixes #1231 (fixed broken logic)
2 parents d535626 + 06c2bb8 commit 7436fc6

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

RetailCoder.VBE/Inspections/CodeInspectionQuickFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public CodeInspectionQuickFix(ParserRuleContext context, QualifiedSelection sele
2020
public ParserRuleContext Context { get { return _context; } }
2121
public QualifiedSelection Selection { get { return _selection; } }
2222

23-
public bool IsCancelled { get; protected set; }
23+
public bool IsCancelled { get; set; }
2424

2525
public abstract void Fix();
2626

RetailCoder.VBE/Inspections/EncapsulatePublicFieldInspectionResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public override void Fix()
5757
var factory = new EncapsulateFieldPresenterFactory(_parseResult, new ActiveCodePaneEditor(vbe, _wrapperFactory), view);
5858
var refactoring = new EncapsulateFieldRefactoring(factory, new ActiveCodePaneEditor(vbe, _wrapperFactory));
5959
refactoring.Refactor(_target);
60-
IsCancelled = view.DialogResult == DialogResult.Cancel;
60+
IsCancelled = view.DialogResult != DialogResult.OK;
6161
}
6262
}
6363

RetailCoder.VBE/UI/CodeInspections/InspectionResultsViewModel.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,25 +183,22 @@ private void ExecuteQuickFixes(IEnumerable<CodeInspectionQuickFix> quickFixes)
183183
{
184184
var fixes = quickFixes.ToList();
185185
var completed = 0;
186+
var cancelled = 0;
186187
foreach (var quickFix in fixes)
187188
{
188-
// if we have more than 1 fix to run, one cancelled should cancel all remaining fixes:
189-
if (!fixes.Any(fix => fix.IsCancelled))
190-
{
191-
quickFix.Fix();
192-
if (quickFix.IsCancelled)
193-
{
194-
completed++;
195-
}
196-
}
197-
else
189+
quickFix.IsCancelled = false;
190+
quickFix.Fix();
191+
completed++;
192+
193+
if (quickFix.IsCancelled)
198194
{
199-
break; // no need to keep iterating
195+
cancelled++;
196+
break;
200197
}
201198
}
202199

203200
// refresh if any quickfix has completed without cancelling:
204-
if (completed != 0)
201+
if (completed != 0 && cancelled < completed)
205202
{
206203
Task.Run(() => ExecuteRefreshCommandAsync(null));
207204
}

0 commit comments

Comments
 (0)