Skip to content

Commit

Permalink
Merge pull request #3004 from rchande/dashboardnavigation
Browse files Browse the repository at this point in the history
Rename dashboard navigation tweaks

Fixes #44
  • Loading branch information
Ravi Chande committed May 29, 2015
2 parents 0bfe641 + 88a2781 commit 84aad8b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.CodeAnalysis.Editor.Shared.SuggestionSupport;
using Microsoft.CodeAnalysis.Notification;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Text;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Editor.Implementation.InlineRename
Expand Down Expand Up @@ -58,14 +59,6 @@ public void ExecuteCommand(RenameCommandArgs args, Action nextHandler)

private void ExecuteRenameWorker(RenameCommandArgs args, CancellationToken cancellationToken)
{
// If there is already an active session, focus its dashboard;
if (_renameService.ActiveSession != null)
{
var dashboard = GetDashboard(args.TextView);
dashboard.Focus();
return;
}

var snapshot = args.SubjectBuffer.CurrentSnapshot;
Workspace workspace;
if (!Workspace.TryGetWorkspace(snapshot.AsText().Container, out workspace))
Expand All @@ -80,6 +73,25 @@ private void ExecuteRenameWorker(RenameCommandArgs args, CancellationToken cance
return;
}

// If there is already an active session, commit it first
if (_renameService.ActiveSession != null)
{
// Is the caret within any of the rename fields in this buffer?
// If so, focus the dashboard
SnapshotSpan editableSpan;
if (_renameService.ActiveSession.TryGetContainingEditableSpan(caretPoint.Value, out editableSpan))
{
var dashboard = GetDashboard(args.TextView);
dashboard.Focus();
return;
}
else
{
// Otherwise, commit the existing session and start a new one.
_renameService.ActiveSession.Commit();
}
}

var position = caretPoint.Value;
var document = args.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
if (document == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Dashboard(

this.Focus();
textView.Caret.IsHidden = false;
ShouldReceiveKeyboardNavigation = true;
ShouldReceiveKeyboardNavigation = false;
}

private void ShowCaret()
Expand Down

0 comments on commit 84aad8b

Please sign in to comment.