Bug 491712

Summary: Text file with extension other than .txt has an empty icon unless you put content in it.
Product: [Frameworks and Libraries] frameworks-kio Reporter: kocelfc
Component: generalAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal CC: fanzhuyifan, kdelibs-bugs, kfm-devel
Priority: NOR    
Version: 6.4.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description kocelfc 2024-08-14 12:24:42 UTC
If you try to create a text file with an extension other than .txt by using Create New > Text file, the file that gets created has an empty icon and appears as "Empty document" in the properties of the file until you open it, and edit it to put something in it with Kate for example.

I tested a Live ISO with Fedora 40 KDE which has KDE Plasma 6.0.3 and Dolphin 24.02.1 and the file is created with an icon, and in properties it appears as "Plain text document".

STEPS TO REPRODUCE
1. Create a new text file with an extension different than .txt (for example .cfg or .conf)
2. Notice that the icon is empty and it's listed as "Empty document" in properties
3. Edit the file with Kate and put something in it.
4. The file has an icon now and it appears as "Plain text document"

OBSERVED RESULT

File is created with no icon

EXPECTED RESULT

File has an icon

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.4.0
Qt Version: 6.7.2
Kernel Version: 6.6.45-1-lts (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 7800X3D 8-Core Processor
Memory: 30.4 GiB of RAM
Graphics Processor: AMD Radeon RX 6800
Comment 1 kocelfc 2024-08-14 16:38:06 UTC
Doesn't appear to be a Dolphin bug. It started somewhere between kio versions 6.3.0 and 6.4.0.
Comment 2 kocelfc 2024-08-14 16:57:34 UTC
Bisect led to 

commit 3b5a569733511ba6d4fe3896d9891390e928d535 (HEAD)
Author: Nate Graham <nate@kde.org>
Date:   Sun Jun 30 09:48:47 2024 -0600

    Remove unnecessary space character in empty text file template
    
    BUG: 487768
    FIXED-IN: 6.4

 src/new_file_templates/TextFile.txt | 1 -
 1 file changed, 1 deletion(-)

https://invent.kde.org/frameworks/kio/-/commit/3b5a569733511ba6d4fe3896d9891390e928d535
Comment 3 fanzhuyifan 2024-08-14 17:07:41 UTC
If you run `xdg-mime query filetype a.cfg` on an empty a.cfg, it will return "application/x-zerosize". This is because .cfg extensions are not present in the mime types database. So dolphin using an empty icon and saying its file type is empty document is intentional behavior.