more accurate caret position after DCD find location

This commit is contained in:
Basile Burg 2015-03-17 01:34:12 +01:00
parent cfb5e2009d
commit 3a5b9cf941
1 changed files with 8 additions and 6 deletions

View File

@ -364,7 +364,7 @@ end;
procedure TCEEditorWidget.getSymbolLoc; procedure TCEEditorWidget.getSymbolLoc;
var var
srcpos, i, sum: Integer; srcpos, i, sum, linelen: Integer;
fname: string; fname: string;
len: byte; len: byte;
begin begin
@ -381,14 +381,16 @@ begin
len := getLineEndingLength(fDoc.fileName); len := getLineEndingLength(fDoc.fileName);
for i := 0 to fDoc.Lines.Count-1 do for i := 0 to fDoc.Lines.Count-1 do
begin begin
sum += length(fDoc.Lines.Strings[i]); linelen := length(fDoc.Lines.Strings[i]);
sum += len; if sum + linelen + len > srcpos then
//TODO-cenhancement: find declaration, determine column accurately.
if sum >= srcpos then
begin begin
fDoc.CaretY := i+1; fDoc.CaretY := i + 1;
fDoc.CaretX := srcpos - sum + len;
fDoc.SelectWord;
break; break;
end; end;
sum += linelen;
sum += len;
end; end;
end; end;
end; end;