Skip to content

Commit

Permalink
fix: Prevent .txt files being associated with wrong content types
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Feb 14, 2024
1 parent 38bd03e commit c0c9394
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 5 additions & 4 deletions org.eclipse.tm4e.language_pack/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<content-type id="org.eclipse.tm4e.language_pack.basetype"
base-type="org.eclipse.core.runtime.text"
name="Text (Syntax Highlighting)"
priority="low" />
priority="low"
file-names="WORKAROUND_SO_THAT_THIS_CONTENTTYPE_IS_NOT_ASSOCIATED_WITH_TXT_FILES_SEE_ISSUE_703" />
</extension>

<!-- use "Generic Text Editor" for all contributes languages -->
Expand Down Expand Up @@ -679,7 +680,7 @@
<!-- ======================================== -->
<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type id="org.eclipse.tm4e.language_pack.cpp_embedded_latex" name="C++ embedded Latex" base-type="org.eclipse.tm4e.language_pack.basetype" priority="low"
/>
file-names="WORKAROUND_SO_THAT_THIS_CONTENTTYPE_IS_NOT_ASSOCIATED_WITH_TXT_FILES_SEE_ISSUE_703" />
</extension>
<extension point="org.eclipse.tm4e.registry.grammars">
<grammar scopeName="source.cpp.embedded.latex" path="syntaxes/latex/cpp_embedded_latex.tmLanguage.json" />
Expand Down Expand Up @@ -715,7 +716,7 @@
<!-- ======================================== -->
<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type id="org.eclipse.tm4e.language_pack.markdown_latex_combined" name="Markdown Latex combined" base-type="org.eclipse.tm4e.language_pack.basetype" priority="low"
/>
file-names="WORKAROUND_SO_THAT_THIS_CONTENTTYPE_IS_NOT_ASSOCIATED_WITH_TXT_FILES_SEE_ISSUE_703" />
</extension>
<extension point="org.eclipse.tm4e.registry.grammars">
<grammar scopeName="text.tex.markdown_latex_combined" path="syntaxes/latex/markdown_latex_combined.tmLanguage.json" />
Expand Down Expand Up @@ -831,7 +832,7 @@
<!-- ======================================== -->
<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type id="org.eclipse.tm4e.language_pack.markdown-math" name="Markdown Math" base-type="org.eclipse.tm4e.language_pack.basetype" priority="low"
/>
file-names="WORKAROUND_SO_THAT_THIS_CONTENTTYPE_IS_NOT_ASSOCIATED_WITH_TXT_FILES_SEE_ISSUE_703" />
</extension>
<extension point="org.eclipse.tm4e.registry.grammars">
<grammar scopeName="text.html.markdown.math" path="syntaxes/markdown-math/markdown-math.tmLanguage.json" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,16 @@ private void updatePluginXML() throws IOException {
fileExtensions = fileExtensions.stream().distinct().sorted().toList();
fileNames = fileNames.stream().distinct().sorted().toList();
filePatterns = filePatterns.stream().distinct().sorted().toList();

templateVars.put("file_associations", Arrays.asList( //
final String fileAssociations = Arrays.asList( //
fileExtensions.isEmpty() ? null : "file-extensions=\"" + join(fileExtensions, ",") + "\"", //
fileNames.isEmpty() ? null : "file-names=\"" + join(fileNames, ",") + "\"", //
filePatterns.isEmpty() ? null : "file-patterns=\"" + join(filePatterns, ",") + "\"" //
).stream().filter(Objects::nonNull).collect(Collectors.joining(" ")));
).stream().filter(Objects::nonNull).collect(Collectors.joining(" "));

templateVars.put("file_associations",
fileAssociations.isBlank()
? "file-names=\"WORKAROUND_SO_THAT_THIS_CONTENTTYPE_IS_NOT_ASSOCIATED_WITH_TXT_FILES_SEE_ISSUE_703\""
: fileAssociations);

pluginLines.append(render(
"""
Expand Down

0 comments on commit c0c9394

Please sign in to comment.