macOS file comparison with Visual Studio Code

Get help for specific problems
Posts: 2
Joined: 16 Mar 2020

Craby

Hello,

I struggling to make it work for me.

I have FFS (v10.20) and Visual Studio Code (v1.43.0) installed on macOS Mojave (v10.14.6) and would like to add a file compare context menu command, so

#1: I added Visual Studio Code to my path as explained on their site:
"Open the Command Palette (F1) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command."

After this, I am able to launch Terminal and run:

code --diff <file1> <file2>


#2: So I added the following option to FFS at 'Customize context menu':

Description: Compare with Visual Studio Code
Command line: code --diff "%local_path%" "%local_path2%"

So far, it does nothing. No errors. No windows opened. Why?

Thanks for your help in advance!
Craby
Posts: 2
Joined: 16 Mar 2020

Craby

I found out the solution myself, I hope this will help others, too:

The solution is to configure Visual Studio Code as external file compare (diff) tool in FreeFileSync as follows:

Description: Compare with Visual Studio Code
Command line: /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron --diff "%local_path%" "%local_path2%"

Note the backslashes (\) to escape the spaces... without these it fails silently.

Enjoy!
Craby
Posts: 345
Joined: 7 Jan 2018

bgstack15

Thank you for sharing the solution! It makes a lot of sense in a Unix-based platform that you would need to escape the spaces, but not everyone will know to do that.
User avatar
Site Admin
Posts: 7506
Joined: 9 Dec 2007

Zenju

Description: Compare with Visual Studio Code
Command line: code --diff "%local_path%" "%local_path2%"

So far, it does nothing. No errors. No windows opened. Why? Craby, 16 Mar 2020, 19:38
Errors are not reported because the command is run asynchronously. Only when starting more than 10 commands FFS will show a warning and run them one after another => bonus: if an error occurs it will be notified.

Anyway, I tried to reproduce the issue, and at first I also wasn't able to run "code --diff". I made some code changes, and suddently it worked! Then I reverted these code changes, and "code --diff" *still worked*. So I suspect there was a buffering issue, or a permissions issue (I believe VScode asked for file access permissions once and I granted them).