diff --git a/src/ce_common.pas b/src/ce_common.pas index 88725a73..dabc51e0 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -205,8 +205,10 @@ type function AppIsRunning(const ExeName: string):Boolean; (** - * Returns the length of the line ending of the system + * Returns the length of the line ending in aFilename; *) + //function getLineEndingLength(const aFilename: string): byte; + function getSysLineEndLen: byte; implementation @@ -756,6 +758,36 @@ begin aProcess.Options := aProcess.Options + [poNewConsole]; end; +// TODO-cbugfix: confirm that DCD location info are based on system Line ending and not the one existing in a specific file + +//function getLineEndingLength(const aFilename: string): byte; +//var +// value: char; +// le: string; +//begin +// value := #0; +// le := LineEnding; +// result := length(le); +// if not fileExists(aFilename) then +// exit; +// with TMemoryStream.Create do +// try +// LoadFromFile(aFilename); +// while true do +// begin +// if Position = Size then +// exit; +// read(value,1); +// if value = #10 then +// exit(1); +// if value = #13 then +// exit(2); +// end; +// finally +// Free; +// end; +//end; + function getSysLineEndLen: byte; begin {$IFDEF WINDOWS} diff --git a/src/ce_editor.pas b/src/ce_editor.pas index 37603846..41d031a7 100644 --- a/src/ce_editor.pas +++ b/src/ce_editor.pas @@ -375,7 +375,10 @@ begin openDocument(fname); if srcpos <> -1 then begin + // note: SelStart only matches srcpos if the target file has the same line ending + // as the operating system: the pos has to be found manually. sum := 0; + //len := getLineEndingLength(fDoc.fileName); len := getSysLineEndLen; for i := 0 to fDoc.Lines.Count-1 do begin diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index e3548a50..64751295 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -620,9 +620,9 @@ var i, len: Integer; begin result := 0; - len := getSysLineEndLen; + //len := getLineEndingLength(fFilename); for i:= 0 to fMousePos.y-2 do - result += length(Lines.Strings[i]) + len; + result += length(Lines.Strings[i]) + getSysLineEndLen; result += fMousePos.x; end;