-
Notifications
You must be signed in to change notification settings - Fork 82
Closed
Labels
Description
Word at cursor should return word even cursor is just behind the word. Current behavior:
|word - true
wo|rd - true
word| - false
I suggest to make modification of this behavior
Unit Synedit.PAS
function TCustomSynEdit.GetWordAtRowCol(XY: TBufferCoord): string;
var
Line: string;
Len, Start, Stop: Integer;
begin
Result := '';
if (XY.Line >= 1) and (XY.Line <= Lines.Count) then
begin
Line := Lines[XY.Line - 1];
Len := Length(Line);
{ Len + 1 is for case when word is the last word and cursor is behind it }
if (Len > 0) and
((XY.Char >= 1) and (XY.Char <= Len + 1)) and
(IsIdentChar(Line[XY.Char]) or IsIdentChar(Line[XY.Char-1])) then //Fiala
begin
if IsIdentChar(Line[XY.Char]) then //Fiala
Start := XY.Char
else
Start := XY.Char - 1;
while (Start > 1) and IsIdentChar(Line[Start - 1]) do
Dec(Start);
Stop := XY.Char; //Fiala
while (Stop <= Len + 1) and IsIdentChar(Line[Stop]) do
Inc(Stop);
Result := Copy(Line, Start, Stop - Start);
end;
end;
end;