Example #1
0
        internal static Result <VsCommandTarget> Create(
            IVimBufferCoordinator vimBufferCoordinator,
            IVsTextView vsTextView,
            ITextManager textManager,
            IVsAdapter adapter,
            IDisplayWindowBroker broker,
            IKeyUtil keyUtil,
            IVimApplicationSettings vimApplicationSettings,
            ReadOnlyCollection <ICommandTargetFactory> commandTargetFactoryList)
        {
            var vsCommandTarget = new VsCommandTarget(vimBufferCoordinator, textManager, adapter, broker, keyUtil, vimApplicationSettings);

            var hresult = vsTextView.AddCommandFilter(vsCommandTarget, out IOleCommandTarget nextCommandTarget);

            if (ErrorHandler.Failed(hresult))
            {
                return(Result.CreateError(hresult));
            }

            var commandTargets = commandTargetFactoryList
                                 .Select(x => x.CreateCommandTarget(nextCommandTarget, vimBufferCoordinator))
                                 .Where(x => x != null)
                                 .ToReadOnlyCollection();

            vsCommandTarget.CompleteInit(nextCommandTarget, commandTargets);
            return(Result.CreateSuccess(vsCommandTarget));
        }
Example #2
0
        internal static Result<VsCommandTarget> Create(
            IVimBufferCoordinator vimBufferCoordinator,
            IVsTextView vsTextView,
            ITextManager textManager,
            IVsAdapter adapter,
            IDisplayWindowBroker broker,
            IKeyUtil keyUtil,
            IVimApplicationSettings vimApplicationSettings,
            ReadOnlyCollection<ICommandTargetFactory> commandTargetFactoryList)
        {
            var vsCommandTarget = new VsCommandTarget(vimBufferCoordinator, textManager, adapter, broker, keyUtil, vimApplicationSettings);

            IOleCommandTarget nextCommandTarget;
            var hresult = vsTextView.AddCommandFilter(vsCommandTarget, out nextCommandTarget);
            if (ErrorHandler.Failed(hresult))
            {
                return Result.CreateError(hresult);
            }

            var commandTargets = commandTargetFactoryList
                .Select(x => x.CreateCommandTarget(nextCommandTarget, vimBufferCoordinator))
                .Where(x => x != null)
                .ToReadOnlyCollection();
            vsCommandTarget.CompleteInit(nextCommandTarget, commandTargets);
            return Result.CreateSuccess(vsCommandTarget);
        }