Closed iloveeclipse closed 8 months ago
This looks like a bug in Eclipse Platform to me.
There is this content type registration without any file extensions/file patterns https://github.com/eclipse/tm4e/blob/d5aa3918fb716a8239ae1226180372d84f1b9ae6/org.eclipse.tm4e.language_pack/plugin.xml#L833
which also provides an icon https://github.com/eclipse/tm4e/blob/d5aa3918fb716a8239ae1226180372d84f1b9ae6/org.eclipse.tm4e.language_pack/plugin.xml#L842
and somehow Eclipse associates it with all text files in your case.
Note following: I've set generic editor as default for text content type, and there is code in generic editor that is used by platform to check if it can be used for given files - if it "agrees" it may provide content type platform should use (if I remember it correct). So here I assume it goes to tm4e and that one says markdown. To reproduce, take latest SDK nightly and set generic editor as default as shown in the screenshot.
there is code in generic editor that is used by platform to check if it can be used for given files - if it "agrees" it may provide content type platform should use
can you point me to that code?
I think this is org.eclipse.ui.internal.genericeditor.GenericEditorWithIconAssociationOverride.getEditorDescriptorForFile(IEditorDescriptor, String)
and org.eclipse.ui.internal.genericeditor.GenericEditorWithContentTypeIcon.getImageDescriptor()
Also, is it just the icon that gets changed or is the *.txt file actually markdown syntax highlighted?
In the data.txt you see the numbers seem to be colored, so it looks like syntax highlighting is applied too.
I think it is the return value of org.eclipse.ui.internal.genericeditor.GenericEditorWithIconAssociationOverride.overrideDefaultEditor(String, IContentType, IEditorDescriptor)
that makes the difference now, the question why is the content type assumed to be markdown?
One data point more: this seem to be visible in (not released) tm4e snapshot only, as using TextMate 0.9.0.202401090933 doesn't show the "black markdown" icons while properly indicating that the text files will be opened with generic editor. However, I see that when the files are opened in editor, some syntax highlighting happen.
Do you only have this issue with Eclipse SDK nightly? I don't seem to be able to reproduce it with the currently used target sdk.
Sorry, my fault, I forgot to mention, the only way to see it is with the new feature implemented in the 4.31 SDK, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/1659 implemented (see https://eclipse.dev/eclipse/news/4.31/platform.php#default_editor_preference).
So in the Content Types, I've manually set generic text editor as default for "Text" content type (before it was "Plain Text Editor"):
I changed my target file to:
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/releases/2024-03/"/>
<unit id="org.eclipse.equinox.executable.feature.group" version="0.0.0"/>
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
</location>
which gives me:
But I don't see that "Default" button:
How can I get the right platform binaries into my target file?
I assume you should use https://download.eclipse.org/eclipse/updates/4.31-I-builds repo as there is no final release yet.
Or just grab latest SDK build from https://download.eclipse.org/eclipse/downloads/drops4/I20240213-1800 and install tm4e snapshot build on top (which is what I did).
Ok, I could reproduce it. As I suspected, the issue is in the Eclipse Platform. When querying content types for a file, eventually ContentTypeCatalog#selectMatchingByName will be invoked.
When this method is called with the file extension "txt" it will return the directly mapped contenttype org.eclipse.core.runtime.text
and all child content types that have no "builtInAssociations", e.g. have no file-extensions
, file-patterns
, file-names
defined. So it will return these additional content types if the language pack is installed:
I don't think this behavior is correct.
I will check that tomorrow, but why is this problem visible with the snapshot tm4e build but not with released version?
why is this problem visible with the snapshot tm4e build but not with released version?
I don't know.
But it gets more funky. Depending on how a content type is registered, it will be automatically associated with *.txt
or not by the Eclipse platform.
<extension point="org.eclipse.core.contenttype.contentTypes">
<!-- this content type will NOT be reported by
Platform.getContentTypeManager().findContentTypesFor("txt") -->
<content-type
id="contenttype.green"
base-type="org.eclipse.core.runtime.text"
name="Green"
file-extensions="green" />
<!-- this content type will be reported by
Platform.getContentTypeManager().findContentTypesFor("txt") -->
<content-type
id="contenttype.blue"
base-type="org.eclipse.core.runtime.text"
name="Blue" />
<file-association
content-type="contenttype.blue"
file-extensions="blue" />
</extension>
I merged PR #706 with a temporary workaround. But I don't think this can be the solution. The issue with wrongly associated content types also applies to other plugins. E.g. when you have wildwebdeveloper installed ContentTypeManager will report org.eclipse.wildwebdeveloper.parent
as content type of *.txt
files.
Thanks for quick workaround. Unfortunately, 4.31 M3 build is almost over, and I have no tested fix yet, but I've created https://github.com/eclipse-platform/eclipse.platform/issues/1207 to follow up.
I'm going t close this issue for now as there isn't much more we can do in tm4e.
I've played with latest tm4e snapshot from today from https://download.eclipse.org/tm4e/snapshots/ and see some strange issue probably related to wrong content type detected by tm4e.
HebrewSample.txt
data.txt
test.txt
test.txt
is even empty file.The files attached above are just random text files I had in my workspace that are supposed to be "plain text" files without any syntax etc, but they seem to be recognized as markdown? content type and show an ugly black icon.
Here how it looks like:
Two issues here: 1) Ugly black icon probably wasn't meant to be ugly, but just has wrong background set (should be transparent, isn't). 2) The content type detection seem to go mad. I would expect none of the files above should be linked to the markdown? content type.