Example #1
0
        void ICommandHandler <CommitUniqueCompletionListItemCommandArgs> .ExecuteCommand(
            CommitUniqueCompletionListItemCommandArgs args, Action nextHandler)
        {
            AssertIsForeground();

            if (sessionOpt == null)
            {
                // User hit ctrl-space.  If there was no completion up then we want to trigger
                // completion.
                var completionService = this.GetCompletionService();
                if (completionService == null)
                {
                    return;
                }

                var trigger = new CompletionTrigger(CompletionTriggerKind.InvokeAndCommitIfUnique);
                if (!StartNewModelComputation(completionService, trigger))
                {
                    return;
                }
            }

            if (sessionOpt.InitialUnfilteredModel == null && !ShouldBlockForCompletionItems())
            {
                // We're in a language that doesn't want to block, but hasn't computed the initial
                // set of completion items.  In this case, we asynchronously wait for the items to
                // be computed.  And if nothing has happened between now and that point, we proceed
                // with committing the items.
                CommitUniqueCompletionListItemAsynchronously();
                return;
            }

            // We're either in a language that is ok with blocking, or we have the initial set
            // of items.  Wait until we're done filtering them, then get the selected item.  If
            // it's unique, then we want to commit it.
            var model = WaitForModel();

            if (model == null)
            {
                // Computation failed.  Just pass this command on.
                nextHandler();
                return;
            }

            CommitIfUnique(model);
        }
Example #2
0
        void ICommandHandler <CommitUniqueCompletionListItemCommandArgs> .ExecuteCommand(
            CommitUniqueCompletionListItemCommandArgs args, Action nextHandler)
        {
            AssertIsForeground();

            if (sessionOpt == null)
            {
                // User hit ctrl-space.  If there was no completion up then we want to trigger
                // completion.
                var completionService = this.GetCompletionService();
                if (completionService == null)
                {
                    return;
                }

                if (!StartNewModelComputation(completionService, filterItems: true, dismissIfEmptyAllowed: true))
                {
                    return;
                }
            }

            // Get the selected item.  If it's unique, then we want to commit it.
            var model = this.sessionOpt.WaitForModel();

            if (model == null)
            {
                // Computation failed.  Just pass this command on.
                nextHandler();
                return;
            }

            // Note: Dev10 behavior seems to be that if there is no unique item that filtering is
            // turned off.  However, i do not know if this is desirable behavior, or merely a bug
            // with how that convoluted code worked.  So I'm not maintaining that behavior here.  If
            // we do want it through, it would be easy to get again simply by asking the model
            // computation to remove all filtering.

            if (model.IsUnique)
            {
                // We had a unique item in the list.  Commit it and dismiss this session.
                this.CommitOnNonTypeChar(model.SelectedItem, model);
            }
        }
 CommandState ICommandHandler <CommitUniqueCompletionListItemCommandArgs> .GetCommandState(CommitUniqueCompletionListItemCommandArgs args, Func <CommandState> nextHandler)
 {
     AssertIsForeground();
     return(nextHandler());
 }
 void ICommandHandler <CommitUniqueCompletionListItemCommandArgs> .ExecuteCommand(CommitUniqueCompletionListItemCommandArgs args, Action nextHandler)
 {
     AssertIsForeground();
     ExecuteCommandWorker(args, nextHandler);
 }
 void IChainedCommandHandler <CommitUniqueCompletionListItemCommandArgs> .ExecuteCommand(CommitUniqueCompletionListItemCommandArgs args, Action nextHandler, CommandExecutionContext context)
 {
     AssertIsForeground();
     ExecuteCommandWorker(args, nextHandler, context);
 }
 VSCommanding.CommandState IChainedCommandHandler <CommitUniqueCompletionListItemCommandArgs> .GetCommandState(CommitUniqueCompletionListItemCommandArgs args, Func <VSCommanding.CommandState> nextHandler)
 {
     AssertIsForeground();
     return(GetCommandStateWorker(args, nextHandler));
 }