AvalonStudio.TextEditor.TextEditor.GetPreviousWordAtIndex C# (CSharp) Method

GetPreviousWordAtIndex() public method

public GetPreviousWordAtIndex ( int index ) : string
index int
return string
        public string GetPreviousWordAtIndex(int index)
        {
            var lastWordIndex = TextUtilities.GetNextCaretPosition(TextDocument, index, TextUtilities.LogicalDirection.Backward, TextUtilities.CaretPositioningMode.WordBorder);

            if (lastWordIndex >= 0 && TextDocument.GetLocation(lastWordIndex).Line == TextDocument.GetLocation(index).Line)
            {
                return GetWordAtIndex(lastWordIndex);
            }
            else
            {
                return GetWordAtIndex(index);
            }
        }