-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange (markdown?) content type set for unrelated text files #703
Comments
This looks like a bug in Eclipse Platform to me. There is this content type registration without any file extensions/file patterns which also provides an icon 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. |
can you point me to that code? |
I think this is |
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 |
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. |
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 eclipse-platform/eclipse.platform.ui#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 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
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? |
I don't know. But it gets more funky. Depending on how a content type is registered, it will be automatically associated with <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 |
Thanks for quick workaround. Unfortunately, 4.31 M3 build is almost over, and I have no tested fix yet, but I've created eclipse-platform/eclipse.platform#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:
The text was updated successfully, but these errors were encountered: