Пример #1
0
        public static string GetPreviousWordAtIndex(this ITextDocument document, int index)
        {
            var lastWordIndex = TextUtilities.GetNextCaretPosition(document, index, LogicalDirection.Backward, CaretPositioningMode.WordBorder);

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