protected virtual int GetDataTipTextImpl(TextSpan[] pSpan, out string pbstrText) { pbstrText = null; var debugInfo = _languageService.LanguageDebugInfo; if (debugInfo != null) { var subjectBuffer = WpfTextView.GetBufferContainingCaret(); if (subjectBuffer == null) { return(VSConstants.E_FAIL); } var vsBuffer = EditorAdaptersFactory.GetBufferAdapter(subjectBuffer); // TODO: broken in REPL if (vsBuffer == null) { return(VSConstants.E_FAIL); } return(debugInfo.GetDataTipText(vsBuffer, pSpan, pbstrText)); } return(VSConstants.E_FAIL); }
protected override ITextBuffer GetSubjectBufferContainingCaret() { var result = WpfTextView.GetBufferContainingCaret(contentType: ContentTypeNames.RoslynContentType); if (result == null) { result = WpfTextView.GetBufferContainingCaret(contentType: PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName); } return(result); }
protected virtual int GetDataTipTextImpl(TextSpan[] pSpan, out string pbstrText) { var subjectBuffer = WpfTextView.GetBufferContainingCaret(); if (subjectBuffer == null) { pbstrText = null; return(VSConstants.E_FAIL); } return(GetDataTipTextImpl(subjectBuffer, pSpan, out pbstrText)); }
protected virtual int GetDataTipTextImpl(TextSpan[] pSpan, AbstractLanguageService <TPackage, TLanguageService> .VsLanguageDebugInfo debugInfo, out string pbstrText) { var subjectBuffer = WpfTextView.GetBufferContainingCaret(); if (subjectBuffer == null) { pbstrText = null; return(VSConstants.E_FAIL); } return(GetDataTipTextImpl(subjectBuffer, pSpan, debugInfo, out pbstrText)); }
protected virtual ITextBuffer GetSubjectBufferContainingCaret() => WpfTextView.GetBufferContainingCaret();
/// <summary> /// Will use the Wpf apis to select a range of code (can handle single points as well) /// </summary> /// <param name="selection"></param> /// <param name="focus">if True, focus the editor</param> /// <returns></returns> public bool SelectRange(EditorSelection selection, bool?focus) { ThreadHelper.ThrowIfNotOnUIThread(); try { if (WpfTextView == null || selection == null) { return(false); } var range = new Range() { Start = selection.Start, End = selection.End }; string log = ""; var rangeLines = WpfTextView.GetLinesFromRange(range.Start.Line, range.End.Line); if (rangeLines != null) { WpfTextView.Selection.Clear(); VirtualSnapshotPoint anchorPoint; VirtualSnapshotPoint activePoint; var startPoint = rangeLines.Item1.Extent.Start + range.Start.Character; if (range.IsPoint()) { anchorPoint = new VirtualSnapshotPoint(new SnapshotPoint(WpfTextView.TextSnapshot, startPoint)); activePoint = new VirtualSnapshotPoint(new SnapshotPoint(WpfTextView.TextSnapshot, startPoint)); } else { int endPosition = rangeLines.Item2.Extent.End; if (range.End.Character != int.MaxValue && rangeLines.Item2.Extent.Start + range.End.Character < endPosition) { endPosition = rangeLines.Item2.Extent.Start + range.End.Character; } anchorPoint = new VirtualSnapshotPoint(new SnapshotPoint(WpfTextView.TextSnapshot, startPoint)); activePoint = new VirtualSnapshotPoint(new SnapshotPoint(WpfTextView.TextSnapshot, endPosition)); } WpfTextView.Selection.Select(anchorPoint, activePoint); log += $"Selecting {nameof(FileName)}={FileName} From {anchorPoint} to {activePoint}"; var span = new SnapshotSpan(WpfTextView.TextSnapshot, Span.FromBounds(rangeLines.Item1.Start, rangeLines.Item2.End)); WpfTextView.ViewScroller.EnsureSpanVisible(span, EnsureSpanVisibleOptions.MinimumScroll); log += $", ensuring Visible"; if (selection.Cursor != null) { var caretLine = WpfTextView.GetLine(selection.Cursor); if (caretLine != null) { int startPosition = caretLine.Extent.Start; if (selection.Cursor.Character != int.MaxValue && caretLine.Extent.Start + selection.Cursor.Character < caretLine.Extent.End) { startPosition = caretLine.Extent.Start + selection.Cursor.Character; } WpfTextView.Caret.MoveTo(new VirtualSnapshotPoint(new SnapshotPoint(WpfTextView.TextSnapshot, startPosition))); WpfTextView.Caret.EnsureVisible(); log += $", caret to ActivePoint={activePoint.Position}"; } } } if (focus == true) { WpfTextView.VisualElement.Focus(); } log += $", focus={focus}"; Log.Verbose(log); return(true); } catch (Exception ex) { Log.Warning(ex, $"{nameof(SelectRange)} Range={@selection} Focus={focus}"); } return(false); }
protected virtual ITextBuffer GetSubjectBufferContainingCaret() { return(WpfTextView.GetBufferContainingCaret()); }