Skip to content

Commit

Permalink
Merge pull request #61509 from CyrusNajmabadi/renameSimple
Browse files Browse the repository at this point in the history
Simplify rename implementation
  • Loading branch information
CyrusNajmabadi authored May 25, 2022
2 parents 8ba416d + 55d3c68 commit c8f0393
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ internal void ApplyReplacementText(bool updateSelection = true)
}
}

internal void Disconnect(bool documentIsClosed, bool rollbackTemporaryEdits)
internal void DisconnectAndRollbackEdits(bool documentIsClosed)
{
_session._threadingContext.ThrowIfNotOnUIThread();

Expand All @@ -307,7 +307,7 @@ internal void Disconnect(bool documentIsClosed, bool rollbackTemporaryEdits)
// Remove any old read only regions we had
UpdateReadOnlyRegions(removeOnly: true);

if (rollbackTemporaryEdits && !documentIsClosed)
if (!documentIsClosed)
{
_session.UndoManager.UndoTemporaryEdits(_subjectBuffer, disconnect: true);
}
Expand Down
13 changes: 5 additions & 8 deletions src/EditorFeatures/Core/InlineRename/InlineRenameSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public void SetPreviewChanges(bool value)
_previewChanges = value;
}

private void Dismiss(bool rollbackTemporaryEdits)
private void DismissUIAndRollbackEdits()
{
_dismissed = true;
_workspace.WorkspaceChanged -= OnWorkspaceChanged;
Expand All @@ -382,7 +382,7 @@ private void Dismiss(bool rollbackTemporaryEdits)
var isClosed = document == null;

var openBuffer = _openTextBuffers[textBuffer];
openBuffer.Disconnect(isClosed, rollbackTemporaryEdits);
openBuffer.DisconnectAndRollbackEdits(isClosed);
}

this.UndoManager.Disconnect();
Expand Down Expand Up @@ -660,15 +660,12 @@ private void LogRenameSession(RenameLogMessage.UserActionOutcome outcome, bool p
}

public void Cancel()
=> Cancel(rollbackTemporaryEdits: true);

private void Cancel(bool rollbackTemporaryEdits)
{
_threadingContext.ThrowIfNotOnUIThread();
VerifyNotDismissed();

LogRenameSession(RenameLogMessage.UserActionOutcome.Canceled, previewChanges: false);
Dismiss(rollbackTemporaryEdits);
DismissUIAndRollbackEdits();
EndRenameSession();
}

Expand Down Expand Up @@ -710,7 +707,7 @@ private bool CommitWorker(bool previewChanges)
if (result == UIThreadOperationStatus.Canceled)
{
LogRenameSession(RenameLogMessage.UserActionOutcome.Canceled | RenameLogMessage.UserActionOutcome.Committed, previewChanges);
Dismiss(rollbackTemporaryEdits: true);
DismissUIAndRollbackEdits();
EndRenameSession();

return false;
Expand Down Expand Up @@ -764,7 +761,7 @@ private void CommitCore(IUIThreadOperationContext operationContext, bool preview
// rename!
using var _ = operationContext.AddScope(allowCancellation: false, EditorFeaturesResources.Updating_files);

Dismiss(rollbackTemporaryEdits: true);
DismissUIAndRollbackEdits();
CancelAllOpenDocumentTrackingTasks();

_triggerView.Caret.PositionChanged += LogPositionChanged;
Expand Down

0 comments on commit c8f0393

Please sign in to comment.