Skip to content

Conversation

@NSExceptional
Copy link
Contributor

@NSExceptional NSExceptional commented Feb 25, 2021

Motivation and Summary of Changes

Right now, VS Code defines the file type description for every file association it creates as "VS Code document", which is not very useful. The file type description is what appears in the Info pane for a file in Finder:

Info pane, PDF document

This PR aims to 1) make it possible to specify specific names at all, and 2) to provide some default names for most of the existing supported file types.

My commit messages and code documentation have more detailed information on the approach I took to this.

Oh, also, I could not for the life of me figure out how to get these changes to build. I ran yarn compile inside build/ and it built the *.js files, but could not get the results published in the final product. If someone can tell me how to do that, I will test it on my machine to ensure it works as expected.

PR Checklist

  • There is no issue associated with this PR, because I just started on a PR first instead of making an issue.
    Do I need to create an issue anyway?

  • I have read through the coding guidelines and I think the only guideline I may be breaking is this one:

    Do not introduce new types or values to the global namespace

    However, I'm not sure where to put the two new types I declared. I need some direction here if my PR cannot be merged because of this.

@ghost
Copy link

ghost commented Feb 25, 2021

CLA assistant check
All CLA requirements met.

@NSExceptional NSExceptional changed the title Provide more specific file type descriptions Provide more specific file type descriptions on macOS Feb 25, 2021
@rzhao271 rzhao271 requested a review from bpasero February 26, 2021 18:45
@rzhao271 rzhao271 removed the request for review from bpasero February 26, 2021 18:53
@NSExceptional NSExceptional force-pushed the darwin-filetypes-pr branch 2 times, most recently from 853a28c to c9d10a8 Compare February 26, 2021 20:14
@NSExceptional
Copy link
Contributor Author

Fixed the build errors, but still haven't actually been able to test it

@bpasero bpasero assigned joaomoreno and unassigned bpasero Feb 27, 2021
@joaomoreno
Copy link
Member

PR Checklist

  • There is no issue associated with this PR, because I just started on a PR first instead of making an issue.
    Do I need to create an issue anyway?

Yeah let's create one.

  • I have read through the coding guidelines and I think the only guideline I may be breaking is this one:

    Do not introduce new types or values to the global namespace

    However, I'm not sure where to put the two new types I declared. I need some direction here if my PR cannot be merged because of this.

You're good here, no worries. 👌

Oh, also, I could not for the life of me figure out how to get these changes to build. I ran yarn compile inside build/ and it built the *.js files, but could not get the results published in the final product. If someone can tell me how to do that, I will test it on my machine to ensure it works as expected.

You'll be able to build an OSS version of VS Code with yarn gulp vscode-darwin, let me know how that goes.

@joaomoreno joaomoreno self-requested a review March 1, 2021 08:52
@joaomoreno
Copy link
Member

@NSExceptional I'll set the PR to draft until you've tested and we're ready for a review.

@joaomoreno joaomoreno added engineering VS Code - Build / issue tracking / etc. macos Issues with VS Code on MAC/OS X install-update VS Code installation and upgrade system issues workbench-os-integration Native OS integration issues and removed engineering VS Code - Build / issue tracking / etc. labels Mar 1, 2021
@joaomoreno joaomoreno marked this pull request as draft March 1, 2021 08:53
@NSExceptional
Copy link
Contributor Author

NSExceptional commented Mar 1, 2021

@joaomoreno No dice, it builds without errors then fails to run :/

Screenshots Screenshot 2021-03-01 at 1 44 18 PM Screenshot 2021-03-01 at 1 44 51 PM

Is it possible I messed something up while snooping around in the OSS build folder? I tried yarn cache clean hoping that would blow away any build artifacts but I'm not sure if it does that

@joaomoreno
Copy link
Member

joaomoreno commented Mar 2, 2021

Try rm -r .build, that will clean the local electron build, so it fetches a new one.

@NSExceptional
Copy link
Contributor Author

NSExceptional commented Mar 2, 2021

That did the trick. It worked! Here's the generated Info.plist

Screenshot 2021-03-02 at 10 59 38 AM

@NSExceptional NSExceptional marked this pull request as ready for review March 3, 2021 23:35
@NSExceptional
Copy link
Contributor Author

Noticed there were no associated file extensions in my screenshot 🤪 Fixed; I was indexing the object improperly in darwinBundleDocumentTypes:

function darwinBundleDocumentTypes(types: { [name: string]: string | string[] },  {
    return Object.keys(types).map((name: string, idx: number): DarwinDocumentType => {
        const extensions = types[idx]; // <-- using idx by mistake
        ...

function darwinBundleDocumentTypes(types: { [name: string]: string | string[] },  {
    return Object.keys(types).map((name: string): DarwinDocumentType => {
        const extensions = types[name]; // <-- use name instead
        ...

@NSExceptional
Copy link
Contributor Author

NSExceptional commented Mar 4, 2021

Compilation is now failing here because of src/vs/workbench/test/browser/api/extHostBulkEdits.test.ts passing an extra argument to a function, but I didn't touch that file or any related files? 😟

@NSExceptional
Copy link
Contributor Author

NSExceptional commented Mar 15, 2021

@joaomoreno Do you know what's going on? I need some guidance

@joaomoreno
Copy link
Member

Just merge main into your branch and let's see if CI gets over that hump.

With this change, to define a document type, you need only pass the name (or relative path) of the darwin icon.

So instead of passing 'resources/darwin/css.icns' you would just pass 'css'
Allow the caller to provide a specific file type description.

The new function will not require source changes to existing calls, but will change how the file type description is generated. An unmodified call to darwinBundleDocumentType will use the given icon name as the file type description. All extensions passed to this function continue to use the same icon as before, and all extensions will have the same file type description as before.
Split darwinBundleDocumentType into two separate functions. The first function is unchanged.

The second function allows you to specify specific names for different groups of extensions while all sharing the same icon. For example, this would allow you to differentiate between a C header and a C source file while using the same icon for both.

Inherently, the second function will generate multiple file type declarations, so it returns an array instead of a single object. As a result we must use the splat operator on it when passing the result to an array literal.
Make use of the changes in the previous commit
@NSExceptional
Copy link
Contributor Author

No wonder, I was rebasing on my local main which was tracking my fork, not upstream 🤦🏻‍♂️

@NSExceptional
Copy link
Contributor Author

@joaomoreno All checks passed!

@joaomoreno joaomoreno added this to the April 2021 milestone Mar 24, 2021
@NSExceptional
Copy link
Contributor Author

@joaomoreno does this have any blockers?

@joaomoreno joaomoreno modified the milestones: April 2021, Backlog Apr 19, 2021
@NSExceptional
Copy link
Contributor Author

@joaomoreno will this be put into the May milestone?

@joaomoreno joaomoreno merged commit 8df547f into microsoft:main Jul 16, 2021
@joaomoreno
Copy link
Member

Thanks! 🍻

@joaomoreno joaomoreno modified the milestones: Backlog, July 2021 Jul 16, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

install-update VS Code installation and upgrade system issues macos Issues with VS Code on MAC/OS X workbench-os-integration Native OS integration issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants