Beispiel #1
0
        public bool TryGetContainingWindowFrame(IVsTextView textView, out IVsWindowFrame windowFrame)
        {
            var result = _uiShell.GetDocumentWindowFrames();

            if (result.IsError)
            {
                windowFrame = null;
                return(false);
            }

            foreach (var frame in result.Value)
            {
                IVsCodeWindow codeWindow;
                if (frame.TryGetCodeWindow(out codeWindow))
                {
                    IVsTextView vsTextView;
                    if (ErrorHandler.Succeeded(codeWindow.GetPrimaryView(out vsTextView)) && NativeMethods.IsSameComObject(vsTextView, textView))
                    {
                        windowFrame = frame;
                        return(true);
                    }

                    if (ErrorHandler.Succeeded(codeWindow.GetSecondaryView(out vsTextView)) && NativeMethods.IsSameComObject(vsTextView, textView))
                    {
                        windowFrame = frame;
                        return(true);
                    }
                }
            }

            windowFrame = null;
            return(false);
        }
Beispiel #2
0
        public void Init()
        {
            {
                var A = new EditorHostFactory();
                var B = A.CreateCompositionContainer();
                IEditorFormatMapService efms = B.GetExportedValue <IEditorFormatMapService>();
                if (!VsSettings.IsInitialized)
                {
                    VsSettings.Initialize(this.pkg, efms);
                }
            }

            CreateMenu();
            cmdExec = new CommandExecutorService()
            {
            };
            disableVsVimCmdAvailable = cmdExec.IsCommandAvailable(VsVimSetDisabled);
            enableVsVimCmdAvailable  = cmdExec.IsCommandAvailable(VsVimSetEnabled);
            viEmuPluginPresent       = cmdExec.IsCommandAvailable(ViEmuEnableDisableCommand);
            iVsUiShell  = Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell;
            iVsUiShell4 = iVsUiShell as IVsUIShell4;
            JumpLabelUserControl.WarmupCache();
            // warmup options
            GeneralOptions.Instance.caretPositionSensivity = GeneralOptions.Instance.caretPositionSensivity;
            // warmp up:
#if MEASUREEXECTIME
            var watch2_0 = System.Diagnostics.Stopwatch.StartNew();
#endif
            var wfs = iVsUiShell.GetDocumentWindowFrames().GetValueOrDefault();
            if (wfs.Count > 0)
            {
                Trace.WriteLine("GetDocumentWindowFrames warmed up");
                foreach (var wf in wfs)
                {
                    wf.GetProperty((int)VsFramePropID.Caption, out var oce);
                    wf.SetProperty((int)VsFramePropID.Caption, (string)oce);
                }
            }
#if MEASUREEXECTIME
            watch2_0.Stop();
            Trace.WriteLine($"PeasyMotion Adornment warmup document tabs: {watch2_0.ElapsedMilliseconds} ms");
#endif
        }
Beispiel #3
0
 internal Result <List <IVsWindowFrame> > GetWindowFrames()
 {
     return(_uiShell.GetDocumentWindowFrames());
 }