public static int FindNextSubwordEndOffset(TextDocument doc, int offset) { int myoffset = offset + 1; if (!OffsetIsWithinBounds(doc, myoffset)) { return(myoffset); } char c = doc.GetCharAt(myoffset); // skip whitespace while (char.IsWhiteSpace(c)) { if (OffsetIsWithinBounds(doc, ++myoffset)) { c = doc.GetCharAt(myoffset); } else { return(offset); } } var initialClass = ViWordFindStrategy.GetCharacterClass(c); while (ViWordFindStrategy.GetCharacterClass(c) == initialClass && 0 <= myoffset && doc.TextLength - 1 > myoffset) { c = doc.GetCharAt(++myoffset); } return(System.Math.Max(offset, myoffset - 1)); }
public static void NextWordEnd(TextEditorData data) { data.Caret.Offset = ViWordFindStrategy.FindNextWordEndOffset(data.Document, data.Caret.Offset); }