Skip to content

Fix incorrect UTI registrations - #1468

Closed
jgvanwyk wants to merge 0 commit into
macvim-dev:masterfrom
jgvanwyk:uti-registrations
Closed

Fix incorrect UTI registrations#1468
jgvanwyk wants to merge 0 commit into
macvim-dev:masterfrom
jgvanwyk:uti-registrations

Conversation

@jgvanwyk

@jgvanwykjgvanwyk commented Dec 23, 2023

Copy link
Copy Markdown

Currently MacVim exports many UTIs for filetypes it doesn't own, and its UTI definitions for many of these filetypes are incorrect. This patch aims to correct these UTI registrations and close#1169. The following lists the UTIs that were changed and how.

BeforeAfter
export org.vim.vim-scriptexport org.vim.vim-script
export org.vim.tex-fileimport org.tug.{tex,sty,cls}
export public.plain-textimport public.plain-text
export public.c-headerimport public.c-header
export org.vim.pch-fileimport public.precompiled-c-header
export public.c-plus-plus-headerimport public.c-plus-plus-header
export org.vim.pch++-fileimport public.precompiled-c-plus-plus-header
export public.c-sourceimport public.c-source
export public.objective-c-sourceimport public.objective-c-source
export public.objective-c-plus-plus-sourceimport public.objective-c-plus-plus-source
export public.c-plus-plus-sourceimport public.c-plus-plus-source
export public.assembly-sourceimport public.assembly-source
export com.apple.rez-sourceimport com.apple.rez-source
export com.sun.java-sourceimport com.sun.java-source
export com.apple.xcode.lex-sourceimport public.lex-source
export com.apple.xcode.yacc-sourceimport public.yacc-source
export public.mig-sourceimport public.mig-source
export com.apple.symbol-exportimport com.apple.symbol-export
export com.apple.xcode.fortran-sourceimport public.fortran{,-77,-90,-95}-source
export com.apple.xcode.pascal-sourceimport public.pascal-source
export public.htmlimport public.html
export public.xmlimport public.xml
export com.netscape.javascript-sourceimport com.netscape.javascript-source
export public.python-scriptimport public.python-script
export public.perl-scriptimport public.perl-script
export public.php-scriptimport public.php-script
export public.ruby-scriptimport public.ruby-script
export public.shell-scriptimport public.{shell,bash,zsh,csh,ksh,tcsh}-script
export com.sun.java-classimport com.sun.java-class
export org.vim.patch-fileimport public.patch-file
export com.apple.xcode.strings-textimport com.apple.xcode.strings-text
export com.apple.applescript.textimport com.apple.applescript.text
export org.vim.as-fileimport com.adobe.actionscript
export org.vim.asp-fileimport com.microsoft.asp
export org.vim.aspx-fileimport com.microsoft.aspx
export org.vim.bib-fileimport org.tug.tex.bibtex
export org.vim.cs-fileimport com.microsoft.c-sharp
export org.vim.cfdg-fileimport org.contextfreeart.contextfree
export org.vim.csv-fileimport public.comma-seperated-values-text
export org.vim.tsv-fileimport public.tab-seperated-values-text
export org.vim.cgi-fileimport org.vim.cgi-script
export org.vim.cfg-fileimport org.vim.config-file
export org.vim.css-fileimport org.w3.css
export org.vim.dtd-fileimport org.w3.xml-dtd
export org.vim.dylan-fileimport public.dylan-source
export org.vim.erl-fileorg.erlang.erlang
export org.vim.fscript-fileorg.fscript.fscript
export org.vim.hs-fileimport org.haskell.haskell
export org.vim.inc-fileimport org.vim.include-file
export org.vim.ics-fileimport com.apple.ical.ics
export org.vim.ini-fileimport com.microsoft.ini
export org.vim.io-fileimport org.iolanguage.io
export org.vim.bsh-fileimport org.beanshell.beanshell
export org.vim.properties-fileimport com.sun.java-properties
export org.vim.jsp-fileimport com.sun.java-server-pages
export org.vim.lisp-fileimport org.vim.lisp-source
export org.vim.log-fileimport com.apple.log
export org.vim.wiki-fileimport org.mediawiki.wiki-source
export org.vim.ps-fileimport com.adobe.postscript
export org.vim.scm-fileimport org.vim.scheme-source
export org.vim.sql-fileimport org.iso.sql
export org.vim.tcl-fileimport tk.tcl.tcl
export org.vim.xsl-fileimport org.w3.xsl
export public.vcardimport public.vcard
export org.vim.vb-fileimport com.microsoft.visual-basic
export org.vim.yaml-fileimport org.yaml.yaml
export org.vim.gtd-fileimport org.vim.gtd
export net.darlingfireball.markdownimport net.darlingfireball.markdown
export org.vim.rst-fileimport org.python.restructuredtext
export org.vim.vba-fileexport org.vim.vimball-archive
export org.vim.vhdl-fileremove
export org.lua.lua-sourceimport org.lua.lua
export org.vim.v-fileimport org.ieee.vhdl
export org.vim.vh-fileimport org.ieee.vhdl-header

@ychin

Copy link
Copy Markdown
Member

Fix for the PR. Let me take a look. This old issue has been sitting on the background but I never bothered to fix it…

@ychin

ychin commented Jan 3, 2024

Copy link
Copy Markdown
Member

I'm sorry for the late response to this (especially since you looked into this in #1169 a few months ago). But looking through this, I am still a little confused if we could just declare CFBundleDocumentTypes instead of using UTImportedTypeDeclarations (see https://stackoverflow.com/questions/21937978/what-are-utimportedtypedeclarations-and-utexportedtypedeclarations-used-for-on-i). Declaring CFBundleDocumentTypes allows the app to open said files already, so I'm still trying to understand exactly why we need to import the UTIs to begin with (but yes, the way MacVim is doing, aka exporting UTIs is just blatantly wrong).

Looking at existing apps, seems like VSCode just uses CFBundleDocumentTypes to declare files it could open but does not import; meanwhile Xcode does import UTIs, so I'm trying to understand the difference here to make sure we do the right thing.

The MacVim Info.plist mentions it's using the exported UTIs to declare what it could use QuickLook for so I may take a look to test if that's also the case for imported UTIs. It does seem like a weak justification IMO but wanted to get all the information first.

As an aside I'm pushing to for r180 for now, since I really want to push r179 (was hoping to get this out by EOY 2023 which obviously didn't happen) which also comes with the new Vim 9.1 release.

@ychin

ychin commented Jan 3, 2024

Copy link
Copy Markdown
Member

Also @hofman since he filed the original issues, in case he didn't see this.

@ychinychin added this to the Release 180 milestone Jan 3, 2024
@jgvanwyk

Copy link
Copy Markdown
Author

I'm sorry for the late response to this (especially since you looked into this in #1169 a few months ago). But looking through this, I am still a little confused if we could just declare CFBundleDocumentTypes instead of using UTImportedTypeDeclarations (see https://stackoverflow.com/questions/21937978/what-are-utimportedtypedeclarations-and-utexportedtypedeclarations-used-for-on-i). Declaring CFBundleDocumentTypes allows the app to open said files already, so I'm still trying to understand exactly why we need to import the UTIs to begin with (but yes, the way MacVim is doing, aka exporting UTIs is just blatantly wrong).

Looking at existing apps, seems like VSCode just uses CFBundleDocumentTypes to declare files it could open but does not import; meanwhile Xcode does import UTIs, so I'm trying to understand the difference here to make sure we do the right thing.

I‘ve finally gotten around to looking at this, and now I understand how the different pieces fit together. CFBundleDocumentTypes and UTImportedTypeDeclarations are meant to be used in conjunction with one another. UTImportedTypeDeclarations informs the system of file types owned by apps other than your own, and CFBundleDocumentTypes informs the system of file types that your app can open.

A typical entry in CFBundleDocumentTypes will include the key LSItemContentTypes, whose value is a uniform type identifier representing the file type that your app can open (if you list an identifier here of which the system is unaware, for example if you did not import it using UTImportedTypes, then your app won't be able to open that file type).

There are two long deprecated alternatives to LSItemContentTypes, namely CFBundleTypeExtensions, which is what MacVim uses currently, and CFBundleTypeOSType, which is what VSCode uses. Both of these mechanisms were deprecated in OS X 10.5 in 2007.

Source: See the section on CFBundleDocumentTypes in https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

What I will do is amend my pull request to update MacVim‘s CFBundleDocumentTypes array to use LSItemContentTypes (I should get around to this tomorrow).

The MacVim Info.plist mentions it's using the exported UTIs to declare what it could use QuickLook for so I may take a look to test if that's also the case for imported UTIs. It does seem like a weak justification IMO but wanted to get all the information first.

MacVim should not export uniform type identifiers it does not own under any circumstances, as it breaks the user‘s file type associations.

@eirnym

Copy link
Copy Markdown
Contributor

@jgvanwyk could you explain cell value import without continuation in PR description?

@ychinychin modified the milestones: Release 180, Release 181Sep 10, 2024
@ychinychin modified the milestones: Release 181, Release 182Feb 19, 2025
@ychinychin modified the milestones: Release 182, Release 183Oct 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UTI registrations are wrong

3 participants

@jgvanwyk@ychin@eirnym