File: InlineRename\CommandHandlers\AbstractRenameCommandHandler_SaveHandler.cs
Web Access
Project: src\src\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj (Microsoft.CodeAnalysis.EditorFeatures)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
 
using Microsoft.CodeAnalysis.InlineRename;
using Microsoft.VisualStudio.Commanding;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
 
namespace Microsoft.CodeAnalysis.Editor.Implementation.InlineRename;
 
internal abstract partial class AbstractRenameCommandHandler : ICommandHandler<SaveCommandArgs>
{
    public CommandState GetCommandState(SaveCommandArgs args)
        => GetCommandState();
 
    public bool ExecuteCommand(SaveCommandArgs args, CommandExecutionContext context)
    {
        // If commit is async, just let editor save the document.
        // If call async commit here, it could finish after the save command so the workspace would still be dirty.
        if (renameService.ActiveSession != null && !globalOptionService.ShouldCommitAsynchronously())
        {
            Commit(context.OperationContext);
            SetFocusToTextView(args.TextView);
        }
 
        return false;
    }
}