[fpc-devel] TStringList.Text and soTrailingLineBreak

Bart bartjunk64 at gmail.com
Thu May 7 20:45:06 CEST 2026


Hi,

Some context.
I process text on the clipboard using a TStringList (too lazy to split
it myself) and noticed that the last empty line went missing.
(Empty lines in the input of this processing will be retruned as a
TStringArray with empty strings, so missing the last empty input line
matters.)

Experimented a bit.

  SL := TStringList.Create;
  writeln('soTrailingLineBreak in SL.Options=',soTrailingLineBreak in
SL.Options);
  SL.Text := 'A'+LineEnding;
  writeln('SL.Count=',SL.Ccount);

this will output:
SL.Count=1

I found it a little bit odd that the last (empty) line wasn't added to
the stringlist.
I thought it might be dependant on wether or not soTrailingLineBreak
was set in Options, but it doesn't.
Apparently soTrailingLineBreak only influences the result of GetTextStr.

Since I don't have Delphi anymore, I cannot test wether this is
compatible or not.
I also could not find in Delphi docs wether soTrailingLineBreak should
influence setting Text.

-- 
Bart


More information about the fpc-devel mailing list