private static string GetWordNearCursor(Scintilla editor) { int caretPos; var s = " " + editor.GetCurrentLine(out caretPos) + " "; caretPos = Math.Min(caretPos, s.Length - 1); do { if (caretPos == 0) break; } while (!IsWordEndChar(s[--caretPos])); for (var i = (++caretPos) + 1; i < s.Length; i++) if (IsWordEndChar(s[i])) return s.Substring(caretPos, i - caretPos); return String.Empty; }