How to open a file in editor from Tracy?

When error page is displayed, you can click on file names and they will open in your editor with the cursor on the corresponding line. Files can also be created (action create file) or bug fixed in them (action fix it). In order to do this, you need to configure the browser and the system.

If you do not change variable Tracy\Debugger::$editor, the Tracy will open the files by using the URL having this format: editor://open/?file=%file&line=%line, i.e. using editor:// protocol. You need to register a handler in your system, which can be any executable file able to process passed URL.

Windows

  1. Download the appropriate files from the Tracy repository to disk.
  2. Edit open-editor.js and uncomment or edit the path to your editor in settings:
var settings = {

    // PhpStorm
    editor: '"C:\\Program Files\\JetBrains\\PhpStorm 2018.1.2\\bin\\phpstorm64.exe" --line %line% "%file%"',
    title: 'PhpStorm',

    // NetBeans
    // editor: '"C:\\Program Files\\NetBeans 8.1\\bin\\netbeans.exe" "%file%:%line%" --console suppress',

    // Sublime Text 2
    // editor: '"C:\\Program Files\\Sublime Text 2\\sublime_text.exe" "%file%:%line%"',

    ....
}

....

Be careful and keep the double slashes in the paths.

3. Register the handler for editor:// protocol in the system.

This is done by running install.cmd. You need to run it as Administrator. The open-editor.js script will now serve the editor:// protocol.

Linux

  1. Download the appropriate files from the Tracy repository to directory ~/bin.
  2. Edit open-editor.sh and uncomment or edit the path to your editor in variable editor:
#!/bin/bash

# Emacs
#editor='emacs +$LINE "$FILE"'

# gVim
#editor='gvim +$LINE "$FILE"'

# gEdit
#editor='gedit +$LINE "$FILE"'

# Pluma
#editor='pluma +$LINE "$FILE"'

...

Make it executable:

chmod +x ~/bin/open-editor.sh

If the editor you are using is not installed from the package, the binary will probably not have a path in $PATH. This can be easily corrected. In the ~/bin directory, create a symlink on the editor binary. note

3. Register the handler for editor:// protocol in the system.

This is done by running install.sh. The open-editor.js script will now serve the editor:// protocol.

Mac OS X

If you use TextMate editor, or another supporting special URL, just configure it in $editor variable:

// PhpStorm
Tracy\Debugger::$editor = 'phpstorm://open?file=%file&line=%line';
// TextMate
Tracy\Debugger::$editor = 'txmt://open/?url=file://%file&line=%line';
// MacVim
Tracy\Debugger::$editor = 'mvim://open/?url=file://%file&line=%line';

Unfortunately, actions create file or fix it do not work on Mac OS X.

Demos

Fixing bug:

Creating a new file:

Troubleshooting

  • in Firefox you may need to allow custom protocol execution in about:config by setting network.protocol-handler.expose.editor to false and network.protocol-handler.expose-all to true. It should be allowed by default however.
  • If it's not all working immediately, don't panic. Try to refresh the page, restart browser or computer. That should help.
  • Input Error: There is no script engine for file extension “.js” Maybe you associated “.js” file to another app, not JScript engine. To fix, see here

In case of more troubles or questions, ask on forum.