Example #1
0
        public bool ExecuteCommand(SurroundWithCommandArgs args, CommandExecutionContext context)
        {
            ThreadingContext.ThrowIfNotOnUIThread();

            if (!AreSnippetsEnabled(args))
            {
                return(false);
            }

            return(TryInvokeInsertionUI(args.TextView, args.SubjectBuffer, surroundWith: true));
        }
Example #2
0
        public CommandState GetCommandState(SurroundWithCommandArgs args)
        {
            ThreadingContext.ThrowIfNotOnUIThread();

            if (!AreSnippetsEnabled(args))
            {
                return(CommandState.Unspecified);
            }

            if (!CodeAnalysis.Workspace.TryGetWorkspace(args.SubjectBuffer.AsTextContainer(), out var workspace))
            {
                return(CommandState.Unspecified);
            }

            if (!workspace.CanApplyChange(ApplyChangesKind.ChangeDocument))
            {
                return(CommandState.Unspecified);
            }

            return(CommandState.Available);
        }