Now you are looking at 2 individual things.
Yes, Line 1 never gets deleted. It must always exist.
Well a new SynEdit does not have it in the lines object. But it behaves as if it exists. Caret is at (1,1).
That has nothing todo with the ranges / range-list. Neither will be destroyed, not even if you manage to delete the last line.
As I said the range-list will exist as long as the HL is attached to the SynEdit.
It gets created on attach, even if SynEdit has no text at the time. So detach is the correct place to remove it.
I do not know what TprimeCobolRangeInfo is / inherits from...
Individual ranges only get destroyed if the HL is destroyed. Otherwise they are kept, and re-used at some time. (as I said, this part of the design is not the best, I have ideas, that need to be tested, and might improve this. But it will be huge work / not now)
Ranges are not kept on the TprimeHighlighterCobolRangeList / TSynHighlighterRangeList.
Those only keep references (and many lines often refer to the same range).
Ranges are on "fRanges: TSynCustomHighlighterRanges;"
Just to say: keep in mind that ranges, once added to fRanges, are immutable.