Bug 340927 - KWrite adds space at the end of each new line
Summary: KWrite adds space at the end of each new line
Status: RESOLVED DUPLICATE of bug 297003
Alias: None
Product: kate
Classification: Applications
Component: kwrite (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR major
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-13 14:50 UTC by Alexander
Modified: 2014-12-12 22:32 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
.desktop for empty file (104 bytes, application/x-desktop)
2014-11-14 13:53 UTC, Boris Egorov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2014-11-13 14:50:31 UTC
Kwrite adds space at the end of each new line

Reproducible: Always

Steps to Reproduce:
1. Create new file
2. Add one line with any text
3. Save
4. Ensure that the new line has space at the end

Remove spaces option should be disabled.
Comment 1 Alexander 2014-11-13 14:51:53 UTC
Qt: 4.8.6
KDE: 4.14.2
KWrite: 4.14.2
Comment 2 Boris Egorov 2014-11-14 08:44:49 UTC
Hmm, can't reproduce it. Are you sure it adds space to *each* line? How do you create file? I found that if you create Text File with dolphin in already has one space in it.

Qt 4.8.6
KDE 4.14.2-2
KWrite 4.14.2-2
Debian Jessie
Comment 3 Alexander 2014-11-14 09:02:52 UTC
You are right, it's a bug in Dolphin, not kate. Once I created a file it contains "\s\n". Can we forward it?
Comment 4 Boris Egorov 2014-11-14 09:24:44 UTC
I dunno. Looks like I can change 'product' right here. In fact, all templates in 'Create New' are created from templates (in my system they live in /usr/share/templates/.source). So the fix will be pretty simple: remove space from TextFile.txt. I don't know if template was created with space intentionally or accidentally.
Comment 5 Boris Egorov 2014-11-14 09:25:39 UTC
*All items in 'Create New' are created from templates
Comment 6 Alexander 2014-11-14 09:37:41 UTC
Thanks.

$ pacman -Qo /usr/share/templates/.source/TextFile.txt
/usr/share/templates/.source/TextFile.txt belongs to kdebase-lib 4.14.2-1

So each upgrade would probably rewrite that template.
Comment 7 Burkhard Lück 2014-11-14 12:38:45 UTC
http://websvn.kde.org/trunk/KDE/kdebase/apps/lib/konq/Templates/TextFile.txt?view=log&pathrev=1000000

Revision 56790 - (view) (download) (annotate) - [select for diffs] 
 Modified Fri Jul 14 12:19:25 2000 UTC (14 years, 4 months ago) by hausmann 
Original Path: trunk/kdebase/kdesktop/init/Templates/TextFile.txt 
File length: 2 byte(s) 
Diff to previous 48936 
- adding a single-small-micro-space :) , so that after creating a new
  textfile with Create New->Text File the icon appears correctly
Comment 8 Burkhard Lück 2014-11-14 13:19:38 UTC
Tested this in stable/master/frameworks compiled from sources with an empty file without extension, an empty file with extension .txt and a file with at least one whitespace with and without extension txt.

They have a different Mimetype and a different icon:

file with at least one whitespace or empty file with an extension (Filename Pattern)  from File Associations settings:
icon text-x-plain mimetyp text plain

empty file without extension:
icon text-x-nfo, mimetyp application-x-zero

From my pov this makes absolutely sense.
Objections to fixed this bug as invalid?
Comment 9 Alexander 2014-11-14 13:39:17 UTC
This sounds incorrect to me. I don't care abut that *** icon, instead I often create new files with Dolphin and have troubles because of those spaces. Doesn't that sound like a real bug? Shouldn't they add an "Empty File" template then?
Comment 10 Boris Egorov 2014-11-14 13:51:55 UTC
(In reply to Alexander from comment #9)
> This sounds incorrect to me. I don't care abut that *** icon, instead I
> often create new files with Dolphin and have troubles because of those
> spaces. Doesn't that sound like a real bug? Shouldn't they add an "Empty
> File" template then?

I found a way to create your own template. You need to:
1. Create directory ~/.kde/share/templates and ~/.kde/share/templates/.source
2. Put file EmptyFile.desktop to ~/.kde/share/templates and EmptyFile to ~/.kde/share/templates/.source

You can even overwrite dolphin's default TextFile template if you create your own template with the same name and different source file.
Comment 11 Boris Egorov 2014-11-14 13:53:05 UTC
Created attachment 89579 [details]
.desktop for empty file
Comment 12 Boris Egorov 2014-11-14 13:56:25 UTC
Can't upload EmptyFile because it's empty =) I think you now how to create it and put to mentioned directory.
Comment 13 Burkhard Lück 2014-11-14 14:03:46 UTC
Please change/correct title, product + component, all are oviously wrong

If you want to have an empty text file, test this with an empty template and ensure that a extension for mimetype text/plain is automatically added. 
Then please file a Review Request at https://git.reviewboard.kde.org/ group kde-baseapps with an empty file lib/konq/Templates/TextFile.txt in the repo kde-baseapps

If you want the option for an emtpty file, add an empty file + the corresponding desktop file to the repository kde-baseapps/lib/konq/Templates/ and file a review request as well
Comment 14 Dominik Haumann 2014-11-14 20:05:47 UTC
As can be seen by the initial commit, the empty space with the newline is intention. This way, new text files are uniquely identified as text files also based on the mime-type. So technically, this is correct I guess.

If you want this changed, I would suggest you bring this topic up on kde-devel@kde.org or even kde-core-devel, since it's been like this for > 10 years an basically noone complained about it.

Besides, you can change your template and then it'll work on your system. It might even work, if you put it locally into ~/.kde4/share/kde4/templates/.source/TextFile.txt or similar.

For me, this is for now a resolved-invalid.
Comment 15 Christoph Feck 2014-12-12 22:32:08 UTC

*** This bug has been marked as a duplicate of bug 297003 ***