Bug: Textpad adding empty lines at end of file when saving

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
Tomas Eklund
Posts: 40
Joined: Tue Mar 16, 2004 1:15 am
Location: Sweden

Bug: Textpad adding empty lines at end of file when saving

Post by Tomas Eklund »

I think I have found something I would call a bug in the most recent version of TextPad (4.7.3). When saving certain text files an unwarranted extra blank line is added to the end of the file.

Steps to reproduce

1) Make sure line numbers are displayed (Configure > Preferences > View > [x] Line numbers)
2) Create a new document
3) Right-click the document tab to edit the properties for the file. Put a check mark before "[x] Word wrap long lines" and "[x] Save with hard breaks" (you may also use "[x] Word break at column number: [20]" to limit the amount of nonsense you'll have to type later). Click OK to apply settings and return to the document.
4) Type some nonsense into the first line of the file making sure that the line is long enough to word wrap.
5) Insert a newline (hit <Enter>) after the first line and type "the end" (or something similar) at the second, last line of the file. Make sure there is no newline after "the end" - the "d" should be the last byte/character of the file.
6) Save the file. Notice how TextPad has put a newline after "the end".

Example

This is what the file looks like in TextPad before saving. Notice that the file has only two lines, but the first line is too long (because of the "Word break at column number 20" setting) and will be broken into two when saving (because of the "Save with hard breaks" setting). There is no newline character after "The end". The numbers at the left are supposed to illustrate the line numbers Textpad is displaying, not someting I have typed in.

Code: Select all

1  This is just some 
   nonsense text.
2  The end
This is what the file looks like after saving. TextPad has put a newline character at the end of the file (why?!). The file should be 3 lines long (because of the wrapping of the first line) but it has become 4 lines long.

Code: Select all

1  This is just some 
2  nonsense text.
3  The end
4  
Add some more text to the first line, so it will word wrap again:

Code: Select all

1  This is just some 
   more 
2  nonsense text.
3  The end
4  
And save. An additional empty line is appended to the file, again.

Code: Select all

1  This is just some 
2  more 
3  nonsense text.
4  The end
5
6  
Insert some more text, but avoid word wrapping:

Code: Select all

1  This is just some 
2  more demonstrational
3  nonsense text.
4  The end
5
6  
And save again. When no word wrapping occurs, no blank lines are appended to the file:

Code: Select all

1  This is just some 
2  more demonstrational
3  nonsense text.
4  The end
5
6  
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

What is your setting for
Configure - Preferences - Editor - Automatically terminate the last line of the file
?

Does it make a difference if you change it?
User avatar
Tomas Eklund
Posts: 40
Joined: Tue Mar 16, 2004 1:15 am
Location: Sweden

Post by Tomas Eklund »

MudGuard wrote:What is your setting for Configure - Preferences - Editor - Automatically terminate the last line of the file? Does it make a difference if you change it?
It is unchecked. And if I check it, the problem persists. So, no difference.

I don't think this problem should have anything to do with "automatic last line termination". If I understand things correctly, automatic last line termination will only occur if the last character of a file is not already a line terminator. But as I have illustrated above, an additional line terminator is repeatedly appended to the file everytime I save it (if word wrapping occurs anywhere in the document) even if the last several lines of the document are empty (consitsts of nothing but line terminators).
Post Reply