public void ActivateItem(int n) { if (tag is DotNetProject) { var proj = ext.ownerProjects [n]; foreach (var doc in ext.textContainer.GetRelatedDocuments()) { if (IdeServices.TypeSystemService.GetMonoProject(doc.Project) is DotNetProject dnp && dnp == proj) { ext.registration.Workspace.SetDocumentContext(doc.Id); } } ext.WorkspaceChanged(null, null); return; } var node = memberList[n]; var editor = ext.textView; int offset; if (node is OperatorDeclarationSyntax) { offset = Math.Max(1, ((OperatorDeclarationSyntax)node).OperatorToken.SpanStart); } else if (node is MemberDeclarationSyntax && !(node is AccessorDeclarationSyntax)) { offset = Math.Max(1, ((MemberDeclarationSyntax)node).SpanStart); } else { offset = node.SpanStart; } //FIXME: use the snapshot that the nodes came from var point = new VirtualSnapshotPoint(editor.TextBuffer.CurrentSnapshot, offset); EditorOperations.SelectAndMoveCaret(point, point, TextSelectionMode.Stream, EnsureSpanVisibleOptions.AlwaysCenter); // TOTEST // editor.Properties.GetProperty<DocumentController> (typeof (DocumentController)).GrabFocus (); }
/// <summary> /// Comment out the currently selected spans. /// </summary> /// <remarks> /// The base implementation calls <see cref="ICommenter.CommentSpans"/> to perform /// the commenting operation and update the currently selected spans. It then /// updates the selection in the editor to match the result of the operation. /// </remarks> protected virtual void CommentSelection() { var undoHistory = TextUndoHistoryRegistry.RegisterHistory(TextView.TextBuffer); using (var transaction = undoHistory.CreateTransaction("Comment Selection")) { EditorOperations.AddBeforeTextBufferChangePrimitive(); bool reversed = TextView.Selection.IsReversed; var newSelection = Commenter.CommentSpans(TextView.Selection.VirtualSelectedSpans); // TODO: detect rectangle selection if present if (newSelection.Count > 0) { VirtualSnapshotPoint anchorPoint = reversed ? newSelection[0].End : newSelection[0].Start; VirtualSnapshotPoint activePoint = reversed ? newSelection[0].Start : newSelection[0].End; EditorOperations.SelectAndMoveCaret(anchorPoint, activePoint); } EditorOperations.AddAfterTextBufferChangePrimitive(); transaction.Complete(); } }
public void ActivateItem(int n) { if (tag is OwnerProjectInfo) { var proj = ext.ownerProjects [n]; foreach (var doc in ext.textContainer.GetRelatedDocuments()) { if (proj.Project.Id == doc.Project.Id) { ext.registration.Workspace.SetDocumentContext(doc.Id); } } ext.WorkspaceChanged(null, null); return; } var node = memberList[n]; var editor = ext.textView; int offset; if (node is OperatorDeclarationSyntax) { offset = Math.Max(1, ((OperatorDeclarationSyntax)node).OperatorToken.SpanStart); } else if (node is MemberDeclarationSyntax && !(node is AccessorDeclarationSyntax)) { offset = Math.Max(1, ((MemberDeclarationSyntax)node).SpanStart); } else { offset = node.SpanStart; } //FIXME: use the snapshot that the nodes came from var point = new VirtualSnapshotPoint(editor.TextBuffer.CurrentSnapshot, offset); EditorOperations.SelectAndMoveCaret(point, point, TextSelectionMode.Stream, EnsureSpanVisibleOptions.AlwaysCenter); }
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode, EnsureSpanVisibleOptions?scrollOptions) => EditorOperations.SelectAndMoveCaret(anchorPoint, activePoint, selectionMode, scrollOptions);
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode) => EditorOperations.SelectAndMoveCaret(anchorPoint, activePoint, selectionMode);