internal static Pos WordLeft(EditorControl ctx, Selection sel) { var caret = sel.Caret; var line = ctx.Buffer.Document.Lines[caret.Line]; if (caret.Col > 0) { var seps = ctx.AffinityManager.GetAffinity(caret).GetNonWordSymbols(ctx); var c = line.CharAt(caret.Col - 1); var strat = SelectWordCommand.GetStrategy(seps, c); var pos = SelectWordCommand.FindBoundLeft(seps, line, caret.Col - 1, strat); if (pos < 0) { return(LeftCommand.MoveLeft(ctx, sel)); } if (Math.Abs(pos - caret.Col) > 1 && pos > 0) { pos++; } return(new Pos(caret.Line, pos)); } else { return(LeftCommand.MoveLeft(ctx, sel)); } }
internal override ActionResults Execute(Selection sel, params object[] args) { var ln = Document.Lines[sel.Caret.Line]; if (sel.Caret.Col == 0) { return(base.Execute(sel)); } var aff = Ed.AffinityManager.GetAffinity(sel.Caret); var seps = aff.NonWordSymbols ?? Ed.EditorSettings.NonWordSymbols; var st = SelectWordCommand.GetStrategy(seps, ln.CharAt(sel.Caret.Col - 1)); var col = SelectWordCommand.FindBoundLeft(seps, ln, sel.Caret.Col - 1, st); sel.End = new Pos(sel.Caret.Line, col != 0 ? col + 1 : col); return(base.Execute(sel)); }