Getting extra lines in a Text Area

I have a Text Area that is receiving lines of text with an extra two EndofLine comments after to make a nice space between each line.

Everything is fine until you go back up in the TextArea and insert the cursor between two lines and hit return twice and insert the next line.

Now, it starts accumulating empty lines at the end of the TextArea. The more line you go up and edit, you always get two extra blank ones at the bottom. It start to add up.

Anyone know how to prevent this from happening?

[quote=213540:@Niles Mitchell]I have a Text Area that is receiving lines of text with an extra two EndofLine comments after to make a nice space between each line.

Everything is fine until you go back up in the TextArea and insert the cursor between two lines and hit return twice and insert the next line.

Now, it starts accumulating empty lines at the end of the TextArea. The more line you go up and edit, you always get two extra blank ones at the bottom. It start to add up.

Anyone know how to prevent this from happening?[/quote]

Mac ? Windows ? Linux ? Got a sample project you can post ?

Windows.

Dim t as TextOutputStream MAIN.SCRIPT_TEXTAREA.SelText=("" + VARIABLE + "=FileGetVersion (" + PATH + ")") MAIN.SCRIPT_TEXTAREA.AppendText(endofline) MAIN.SCRIPT_TEXTAREA.AppendText(endofline)

SelText is replacing the selected text in the text area. As you are just placing the cursor there is no text to replace, so it’s inserted. AppendText adds to the end of the text area. So what you’re getting is what you’re asking for. Change the two AppendTexts to SelText & you’ll get what you want.

Doing that just causes the extra lines to go after the inserted text, instead of at the end of the text.

Doing that simply moves the problem.

I just assumed that the OP wanted to start inserting at the cursor point with his two empty lines for spacing. If he want’s to continue to insert at the end then he needs to change the seltext to a appendtext

Where is the code above placed? If it’s a method, set a breakpoint and you’ll be able to see where it’s getting called from.

I do, Wayne. It’s just that I’m getting 2 blank lines when I do that, not one. If I place the cursor right above a line of text and feed the line in, I wind up with 2 blank lines. This only occurs when I’m inserting in-between existing lines. If It just one after another and I never edit, everything is fine with 1 blank line.

The solution is to place the cursor at the start of the line that needs to move down, and not the live above it. Not intuitive, but functional.