Bug 143120 - change of line ending convention does not trigger the modified attribute on files opened in kate/kwrite
Summary: change of line ending convention does not trigger the modified attribute on f...
Alias: None
Product: kate
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: KWrite Developers
Depends on:
Reported: 2007-03-17 16:53 UTC by Shriramana Sharma
Modified: 2011-06-24 17:31 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.7


Note You need to log in before you can comment on or make changes to this bug.
Description Shriramana Sharma 2007-03-17 16:53:30 UTC
Version:            (using KDE KDE 3.5.6)
OS:                Linux

1. Open a text file in Kate or KWrite.
2. Change its line-ending convention from the Tools > End of Line menu item.

The file should be marked as [modified].

It is not marked as [modified].
Comment 1 Dominik Haumann 2007-03-18 12:50:58 UTC
nothing changed in the buffer. it only has affect, if you save the file explicitly. right now we only have typing stuff in the undo history and no actions.
Comment 2 Anders Lund 2007-03-18 13:13:22 UTC
... but it should, as otherwise it is possible to close kate without a 
warning, and the change is lost.
Comment 3 Christoph Cullmann 2008-08-19 20:30:03 UTC
I like it the way it is. The change does not alter the buffer, if we would mark as modified, we need to implement undo for that, too. Agree with dominik, won't change that behaviour.
Comment 4 Shriramana Sharma 2008-08-26 05:58:27 UTC
Whether it alters the buffer or not is not the matter. Whether it alters the potential *contents* (i.e. bytes) contained in the file is the matter. An editors serves to help the user alter the contents of a file, and the buffer is merely a detail of implementation thereof. Keep in your mind the purpose of the editor.

The point is that the user has made this selection (of changing the line ending) with a clear intent of changing the contents of the file. Some text utilities (on Windows) expect CRLF line endings, some expect LF, and it makes a real difference. If you do not warn the user that he has not saved the changes he/she made, you are not helping him/her, and your warning system is incomplete.

Further, saying that the undo history only works for typing stuff and not for actions is not entirely accurate. Do a "Join lines" script, and that's not "typing", it's an "action", but it causes a new undoable change. You might argue that it changes the buffer, and so it is undoable. Again I say what changes the buffer is not the matter, what changes the contents of the file on disk is the matter.

Therefore, WONTFIX is unjustified. Just because you would need to implement undo for that does not mean you can close this bug as WONTFIX. Reopening it.

What's more, the same should be done for encoding too. If the user selects a different encoding, he wants the bytes to change. If you don't warn of not saving that change, again your warning system is incomplete. If you want, I can open a separate bug for that.
Comment 5 Martin Sondergaard 2008-09-03 15:45:52 UTC
I agree that this bug needs to be fixed.
I was going to report this bug myself, then I found its already reported here.  I'm surprised that this bug has been reported but has not been fixed.

I copied a dozen files over from Windows, and opened them in Kate.  I spent some time going through them all, changing the line endings.  I used Save All, and expected these files to be saved, with the changed line endings.  Later I found the line endings had not been changed permanently, so I opened Kate and tried it again.  I tried this a few times, spending a lot of time trying to get the changed files saved.  

Eventually I found that the only way to save the line endings is to modify each file, by typing in a space character into each file.  Then when I do "Save All", the changed line endings are saved.

For me it is very important that the changed line endings are saved.  I need to use the correct line endings so that I can trace through script files with a debugger.  Without the correct line endings, I cannot use the debugger, and I would be unable to continue work on my program.

I cannot imagine that anyone would change the line endings in Kate, but not want these changes saved to file.  To change these line endings, but have the changes discarded when Kate exits is clearly a waste of time.
Comment 6 Matthew Woehlke 2008-09-04 02:28:41 UTC
It occurs to me, I can see where I would prefer that changes to the file encoding (by which I mean, how it is represented on disk, which includes character-set encoding and also line endings) not get undone with 'undo'... though of course I can see it the other way, also. At any rate, I strongly agree that such changes should be considered modifications.

Would it be too unreasonable to have a second change mode, so we have "buffer changed" (undo-able) and "representation changed" (not undo-able)? We could maybe use "+" instead of "*" for the latter, and of course "buffer changed" would supercede "representation changed" (i.e. don't show both indicators).
Comment 7 Joseph Wenninger 2008-11-30 10:10:20 UTC
I would stay with one modified indicator. And just keep the document in the modified stayed still reloaded or saved, independently of undo/redo steps
Comment 8 Shriramana Sharma 2009-12-16 17:55:15 UTC
I also support one modified indicator. All the indicator shows to the user is "This file needs to be saved!" Whether the content or the (byte) representation is changed is not the matter. Further, these changes of encoding or line endings should not be undo/redoable as from the user's POV undo/redo is for content which they (or someone else) type, not for representation which one does not really "type".
Comment 9 Dominik Haumann 2011-06-24 17:31:34 UTC
fixed for kde 4.7.