public override bool DeletePrevious() { ITextSnapshot snapshot = _textBuffer.AdvancedTextBuffer.CurrentSnapshot; int previousPosition = CurrentPosition - 1; if (previousPosition < 0) { return(true); } int index = previousPosition; char currentCharacter = snapshot[previousPosition]; // By default VS (and many other apps) will delete only the last character // of a combining character sequence. The one exception to this rule is // surrogate pais which we are handling here. if (char.GetUnicodeCategory(currentCharacter) == UnicodeCategory.Surrogate) { index--; } if (index > 0) { if (currentCharacter == '\n') { if (snapshot[previousPosition - 1] == '\r') { index--; } } } return(PrimitivesUtilities.Delete(_textBuffer.AdvancedTextBuffer, index, previousPosition - index + 1)); }
public override bool DeleteNext() { if (_textView.AdvancedTextView.TextViewModel.IsPointInVisualBuffer(AdvancedTextPoint, PositionAffinity.Successor)) { return(PrimitivesUtilities.Delete(GetNextTextElementSpan())); } else { return(_bufferPoint.DeleteNext()); } }
public override bool DeletePrevious() { SnapshotSpan previousElementSpan = GetPreviousTextElementSpan(); if ((previousElementSpan.Length > 0) && (_textView.AdvancedTextView.TextViewModel.IsPointInVisualBuffer(AdvancedTextPoint, PositionAffinity.Successor)) && (!_textView.AdvancedTextView.TextViewModel.IsPointInVisualBuffer(previousElementSpan.End - 1, PositionAffinity.Successor))) { // Since the previous character is not visible but the current one is, delete // the entire previous text element span. return(PrimitivesUtilities.Delete(previousElementSpan)); } else { // Delegate to the buffer point's DeletePrevious implementation to handle deleting single // characters. A single character should be deleted if this point and the previous one // are both visible or both not visible. return(_bufferPoint.DeletePrevious()); } }
public override bool RemovePreviousIndent() { if (Column > 0) { int tabSize = _editorOptions.GetTabSize(); int previousTabStop = Column - tabSize; if (Column % tabSize > 0) { previousTabStop = (Column / tabSize) * tabSize; } int positionToDeleteTo = CurrentPosition; TextPoint newPoint = Clone(); for (int i = CurrentPosition - 1; newPoint.Column >= previousTabStop; i--) { newPoint.MoveTo(i); string character = newPoint.GetNextCharacter(); if (!string.Equals(character, " ", StringComparison.Ordinal) && !string.Equals(character, "\t", StringComparison.Ordinal)) { break; } positionToDeleteTo = i; if (newPoint.Column == previousTabStop) { break; } } return(PrimitivesUtilities.Delete(_textBuffer.AdvancedTextBuffer, Span.FromBounds(positionToDeleteTo, CurrentPosition))); } else { return(true); } }
public override bool DeleteNext() { string nextCharacter = GetNextCharacter(); return(PrimitivesUtilities.Delete(_textBuffer.AdvancedTextBuffer, CurrentPosition, nextCharacter.Length)); }
public override bool Delete() { return(PrimitivesUtilities.Delete(TextBuffer.AdvancedTextBuffer, Span.FromBounds(_startPoint.CurrentPosition, _endPoint.CurrentPosition))); }