kate (erroneously) applies syntax highlighting to plain text files (*.txt)

A recent TW snapshot brought us kate V17.08.0-1.2.

Since then if an existing plain text file with the extension “.txt” is opened, or a new one saved, kate erroneously applies syntax highlighting.


From the menu, “Tools -> Mode” and “Tools -> Highlighting” show that kate has “automagically” selected “Scripts PowerShell” as the file type.

From “Settings → Configure kate… → Open/Save → Modes & Filetypes” it can be seen that associated with “Scripts PowerShell”:

file extensions are *.ps1 *.ps1m and .ps1d - which the plain text file clearly isn’t (.txt).

mime types are text/plain - which the plain text file is.

Removing the mime type results in plain text files correctly opening/saving without highlighting (Mode: Normal / Highlighting: None)

Confirmed on OpenSUSE Leap 42.2 with kate/kwrite 17.08.0, even with a newly created user.

An newly created text-file is already opened with PowerShell highlighting (both kate/kwrite). This is a file created by Dolphin (right-click > Create New > Text File) and contains 2 characters: a space followed by a linefeed. Mime-type is text/plain, as reported by file --mime-type.

An empty file (0 characters) is opened with Normal highlighting (both kate/kwrite).


Upstream bug in the syntax-highlighting framework, should be fixed in 5.38.0 (to be released next Saturday):

Thanks… again :slight_smile:

It seems the commit to fix this issue https://phabricator.kde.org/R216:26daf7ee5b4a4534d918ed7d9e66d64cb30b0c26 simply removes the mime type association from (kate’s) “Modes & Filetypes”, which, as I wrote in the first post, is what I did to “cure” the problem when I first discovered it.

The upstream fix removes the text/plain mimetype from the “Powershell” definition file.
I.e. what you did manually.

You may want to remove your custom config when the update is available, unless you have other modifications…
(I think it should be in .local/share/syntax-highlighting…)

Actually it rather seems to be .config/katemoderc …

OK… Thanks, added a note to my ever growing to-do list :wink: