public void VsTextViewCreated(IVsTextView textViewAdapter) { IWpfTextView view = AdaptersFactory.GetWpfTextView(textViewAdapter); if (!DocumentService.TryGetTextDocument(view.TextBuffer, out ITextDocument doc)) { return; } ITextBufferUndoManager undoManager = UndoProvider.GetTextBufferUndoManager(view.TextBuffer); NodeProcess node = view.Properties.GetOrCreateSingletonProperty(() => new NodeProcess()); AddCommandFilter(textViewAdapter, new PrettierCommand(view, undoManager, node, doc.Encoding, doc.FilePath)); if (!node.IsReadyToExecute()) { node.EnsurePackageInstalledAsync().ConfigureAwait(false); } }
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await JoinableTaskFactory.SwitchToMainThreadAsync(); _dte = ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE)) as DTE2; _serviceProvider = new ServiceProvider((IServiceProvider)_dte); _runningDocTable = new RunningDocumentTable(_serviceProvider); _runningDocTable.Advise(new RunningDocTableEventsHandler(this)); optionPage = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid)); _node = new NodeProcess(this); if (!_node.IsReadyToExecute()) { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed _node.EnsurePackageInstalledAsync().ConfigureAwait(false); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } await base.InitializeAsync(cancellationToken, progress); }