private async Task ExecuteAsync() { IWpfTextView textView = await ServiceProvider.GetWpfTextViewAsync(); if (textView == null) { return; } IMultiSelectionBroker multiSelection = textView.GetMultiSelectionBroker(); if (multiSelection.HasMultipleSelections && multiSelection.AllSelections.Count > 1) { multiSelection.TryRemoveSelection(multiSelection.AllSelections[multiSelection.AllSelections.Count - 1]); } }
private async Task ExecuteAsync() { IWpfTextView textView = await ServiceProvider.GetWpfTextViewAsync(); if (textView == null) { return; } IMultiSelectionBroker multiSelectioBroker = textView.GetMultiSelectionBroker(); if (multiSelectioBroker.HasMultipleSelections) { string firstSelectionValue = multiSelectioBroker.AllSelections[0].Extent.GetText(); if (int.TryParse(firstSelectionValue, out int currentValue)) { using (ITextEdit edit = textView.TextBuffer.CreateEdit()) { for (int i = 0; i < multiSelectioBroker.AllSelections.Count; i++) { multiSelectioBroker.AllSelections[i].ReplaceWith(edit, currentValue.ToString()); currentValue++; } edit.Apply(); } } else if (firstSelectionValue.Length == 1) { char currentChar = firstSelectionValue[0]; using (ITextEdit edit = textView.TextBuffer.CreateEdit()) { for (int i = 0; i < multiSelectioBroker.AllSelections.Count; i++) { multiSelectioBroker.AllSelections[i].ReplaceWith(edit, currentChar.ToString()); currentChar++; } edit.Apply(); } } } }
private async Task ExecuteAsync() { IWpfTextView textView = await ServiceProvider.GetWpfTextViewAsync(); if (textView == null) { return; } IMultiSelectionBroker multiSelection = textView.GetMultiSelectionBroker(); if (!multiSelection.HasMultipleSelections) { var firstSelection = new Selection(textView.Selection.SelectedSpans[0]); multiSelection.SetSelection(firstSelection); } var newSelection = multiSelection.TransformSelection(multiSelection.AllSelections[multiSelection.AllSelections.Count - 1], PredefinedSelectionTransformations.MoveToNextLine); multiSelection.AddSelection(newSelection); }