I use TP to read and sometimes edit source files. We use source control at my company, and once when I was previewing my changes, I found that almost every line had been modified. I eventually discovered that the option "Strip trailing spaces from lines when saving" was on automatically for source files, which meant I had to spend a good 20 minutes going through the entire file and putting all those trailing spaces back so as not to confuse the diff programs.
I think that by default, if I open a file and hit "save," the file's contents should not change unless I've manually changed something. What do you think?
By default, TP should not modify files automatically
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Thanks Ben, that wasn't quite the point though. Disabling the option works as advertised; however, I feel like I shouldn't have had to find it in the first place.
The idea here is, the default behaviour of TP should not be to change your files. The "Strip trailing spaces" option is great, and I would want it in some contexts, but it's a very bad thing to do with source control. Since it's only a minor benefit to have it on by default, but a very big problem (for some users), I think the default should be off.
In general, I think this should apply to any "unexpected" way in which TP might modify your file (eg change \r\n to \n or vice versa, convert tabs to spaces, etc, not that I think it does these things by default anyway). The default should be to leave everything as it is unless the user specifically wants to do something different.
The idea here is, the default behaviour of TP should not be to change your files. The "Strip trailing spaces" option is great, and I would want it in some contexts, but it's a very bad thing to do with source control. Since it's only a minor benefit to have it on by default, but a very big problem (for some users), I think the default should be off.
In general, I think this should apply to any "unexpected" way in which TP might modify your file (eg change \r\n to \n or vice versa, convert tabs to spaces, etc, not that I think it does these things by default anyway). The default should be to leave everything as it is unless the user specifically wants to do something different.
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
I just edited a text file with intentionally some white spaces at the end of the line.I think that by default, if I open a file and hit "save," the file's contents should not change unless I've manually changed something.
I closed the file.
I set the "Strip trailing spaces" for the appropriate document class.
I opened the file.
I changed nothing.
I hit Ctrl-S to save the file.
Nothing happened.
I added a character.
I hit Ctrl-S to save the file.
The file was saved - the trailing spaces were stripped (as expected).
So Textpad did not change the file's content until I manually changed something. That's exactly what you demand.
This is what I get for not actually trying my testcase before I post. Oops. Nice catch MudGuard.
However, it still doesn't change the thrust of my request. If I'm a new user, and I add a single character and hit CTRL-S, it is not at all obvious that this will also strip all the trailing spaces from the rest of the file. (At least, I don't find it obvious). And if I'm a new user editing a source-controlled file, this means a lot of work for me, manually re-adding all those spaces, so my boss doesn't come asking me why I have a 10,000 line diff when all I was supposed to do was change one or two functions. (Yes, our files are 100k+ lines long). This is exactly what happened to me - my change was long, complicated and completely interspersed with all the lines with stripped spaces.
The problem's now fixed (on my computer) but I stand by my claim that the program shouldn't do anything "unexpected" by default. And yes, "Strip Trailing Spaces" is set by default for the C/C++ and Java document classes - exactly the kind of files mostly likely to be under source control. I know that, because I checked this time.
However, it still doesn't change the thrust of my request. If I'm a new user, and I add a single character and hit CTRL-S, it is not at all obvious that this will also strip all the trailing spaces from the rest of the file. (At least, I don't find it obvious). And if I'm a new user editing a source-controlled file, this means a lot of work for me, manually re-adding all those spaces, so my boss doesn't come asking me why I have a 10,000 line diff when all I was supposed to do was change one or two functions. (Yes, our files are 100k+ lines long). This is exactly what happened to me - my change was long, complicated and completely interspersed with all the lines with stripped spaces.
The problem's now fixed (on my computer) but I stand by my claim that the program shouldn't do anything "unexpected" by default. And yes, "Strip Trailing Spaces" is set by default for the C/C++ and Java document classes - exactly the kind of files mostly likely to be under source control. I know that, because I checked this time.
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
I've been hit by precisely this problem. My solution is not to put the spaces back in, but to remove them from a copy of the old file and compare that with the new file. Then (if the only differences that remain are the intended material ones) instruct the source control system to accept all those changes.
Time to find some smaller ones!aludwin wrote:(Yes, our files are 100k+ lines long).
Time to find a new one. :-)aludwin wrote:so my boss doesn't come asking me why
I could certainly instruct our source control to accept the changes, but that destroys our history. Imagine someone comparing a version of the file after my change to the a version before - almost every line will be different. (Of course, we could always get a better diff tool, but I don't get to make decisions like that!)
Looks like I'm loosing this battle though...
Looks like I'm loosing this battle though...
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm