fix, symbol finder, inaccuracy due to line endings

This commit is contained in:
Basile Burg 2015-02-13 04:28:59 +01:00
parent ac27f9c899
commit 33d1fd9cf2
1 changed files with 22 additions and 4 deletions

View File

@ -299,17 +299,35 @@ end;
procedure TCEEditorWidget.getSymbolLoc; procedure TCEEditorWidget.getSymbolLoc;
var var
srcpos: Integer; srcpos, i, sum: Integer;
fname: string; fname: string;
lel: byte;
begin begin
if not DcdWrapper.available then exit; if not DcdWrapper.available then exit;
// //
DcdWrapper.getDeclFromCursor(fname, srcpos); DcdWrapper.getDeclFromCursor(fname, srcpos);
if fname <> fDoc.fileName then if fileExists(fname) then if fname <> fDoc.fileName then if fileExists(fname) then
CEMainForm.openFile(fname); CEMainForm.openFile(fname);
if srcpos <> -1 then begin if srcpos <> -1 then
fDoc.SelStart := srcpos; begin
fDoc.SelectWord; //fDoc.SelStart := srcpos;
//fDoc.SelectWord;
// note: SelStart only matches the srcpos if the target file has the same line ending
// as the operating system: the pos has to be found manually.
sum := 0;
lel := getLineEndingLength(fDoc.fileName);
for i := 0 to fDoc.Lines.Count-1 do
begin
sum += length(fDoc.Lines.Strings[i]);
sum += lel;
//TODO-cenhancement: find declaration, determine column accurately.
if sum >= srcpos then
begin
fDoc.CaretY := i+1;
break;
end;
end;
end; end;
end; end;