Check if document ends in a new line.

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by Douglas Peterson
Version: 4.0.0270
Avatar
I'm appending text, but before I do, I want to make sure that the document ends with a new line. This code works:

    int lineCount = editor.Document.Lines.Count;
    return (lineCount == 0 || editor.Document.Lines[lineCount - 1].Length == 0);
I'm wondering if that's the 'best' way to do it. Is accessing Document.Lines expensive?

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Douglas,

No, Document.Line.Count isn't an expensive call. But please note there is always one line in the document, even if it's empty. So you'd really want to see if there was a single line instead of no lines.


Actipro Software Support

The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.