Example #1
0
        public void PostProcessInvoke(CommandResult result, Guid group, int id, object inputArg, ref object outputArg)
        {
            // only run for VSStd2K commands and if brace completion is enabled
            if (group == VSConstants.VSStd2K)
            {
                if (id == (int)VSConstants.VSStd2KCmdID.TYPECHAR)
                {
                    var typedChar = TypingCommandHandler.GetTypedChar(group, id, inputArg);

                    // handle closing braces if there is an active session
                    if ((Manager.HasActiveSessions && Manager.ClosingBraces.IndexOf(typedChar) > -1) ||
                        Manager.OpeningBraces.IndexOf(typedChar) > -1)
                    {
                        Manager.PostTypeChar(typedChar);
                    }
                }
                // tab, delete, backspace, and return only need to be handled if there is an active session
                // tab and return should be skipped if completion is currently active
                else if (Manager.HasActiveSessions)
                {
                    switch (id)
                    {
                    case (int)VSConstants.VSStd2KCmdID.RETURN:
                        if (!IsCompletionActive)
                        {
                            Manager.PostReturn();
                        }
                        break;

                    case (int)VSConstants.VSStd2KCmdID.TAB:
                        if (!IsCompletionActive)
                        {
                            Manager.PostTab();
                        }
                        break;

                    case (int)VSConstants.VSStd2KCmdID.BACKSPACE:
                        Manager.PostBackspace();
                        break;

                    case (int)VSConstants.VSStd2KCmdID.DELETE:
                        Manager.PostDelete();
                        break;
                    }
                }
            }
        }
Example #2
0
        public CommandResult Invoke(Guid group, int id, object inputArg, ref object outputArg)
        {
            // only run for VSStd2K commands and if brace completion is enabled
            if (group == VSConstants.VSStd2K)
            {
                if (id == (uint)VSConstants.VSStd2KCmdID.TYPECHAR)
                {
                    var typedChar = TypingCommandHandler.GetTypedChar(group, id, inputArg);
                    // handle closing braces if there is an active session
                    if ((Manager.HasActiveSessions && Manager.ClosingBraces.IndexOf(typedChar) > -1) ||
                        Manager.OpeningBraces.IndexOf(typedChar) > -1)
                    {
                        Manager.PreTypeChar(typedChar, out bool handledCommand);
                        if (handledCommand)
                        {
                            return(CommandResult.Executed);
                        }
                    }
                }
                // tab, delete, backspace, and return only need to be handled if there is an active session
                // tab and return should be skipped if completion is currently active
                else if (Manager.HasActiveSessions)
                {
                    switch (id)
                    {
                    case (int)VSConstants.VSStd2KCmdID.RETURN:
                    {
                        if (!IsCompletionActive)
                        {
                            Manager.PreReturn(out bool handledCommand);
                            if (handledCommand)
                            {
                                return(CommandResult.Executed);
                            }
                        }
                        break;
                    }

                    case (int)VSConstants.VSStd2KCmdID.TAB:
                    {
                        if (!IsCompletionActive)
                        {
                            Manager.PreTab(out bool handledCommand);
                            if (handledCommand)
                            {
                                return(CommandResult.Executed);
                            }
                        }
                        break;
                    }

                    case (int)VSConstants.VSStd2KCmdID.BACKSPACE:
                    {
                        Manager.PreBackspace(out bool handledCommand);
                        if (handledCommand)
                        {
                            return(CommandResult.Executed);
                        }
                        break;
                    }

                    case (int)VSConstants.VSStd2KCmdID.DELETE:
                    {
                        Manager.PreDelete(out bool handledCommand);
                        if (handledCommand)
                        {
                            return(CommandResult.Executed);
                        }
                        break;
                    }
                    }
                }
            }
            return(CommandResult.NotSupported);
        }