Jump to content

[solved] IDE links like cursor://file/... not supported for files outside the pw root directory


Recommended Posts

Posted

Hey @adrian this is a bit special, but maybe it's an easy fix, I don't know 🙂 

I love these direct IDE links in dumps that open up the file in question right in my IDE when clicked:

fhWmE9D.png

The problem is that @Sanyaissues and I have been working on improving RockMigrations deployments and Michael also suggested to put all PW files into /public

This leads to a folder structure like this:

/Users/bernhard/projectx
  /public
    /site
    /wire
  /src
    foo.latte
    bar.latte

When I set localRootPath to /Users/bernhard/projectx/public/ links for files inside the PW root work (eg /site/ready.php)

BUT links for files to /src/foo.latte do not 😞 I have all my latte files outside of /public. Also all assets (css/js) are in the /src folder and then compiled, merged and minified via RockDevTools to /public/dst

I was hesitant to go with such a setup at first because I was expecting issues. I already had to refactor my modules to support that setup and there are likely some spots still to fix. But I think it is a great setup and it is worth the effort.

What do you think? Is that something you could support for tracy debugger as well? Maybe it's just do add a new (optional) setting like "projectRoot" so that paths to can properly be rewritten:

/var/www/html/src/foo.latte
/Users/bernhard/projectx/src/foo.latte

/var/www/html/public/site/ready.php
/Users/bernhard/projectx/public/site/ready.php

At the moment the result is this:

/var/www/html/src/foo.latte
/var/www/html/src/foo.latte

/var/www/html/public/site/ready.php
/Users/bernhard/projectx/public/site/ready.php

I guess it's because it does not find $config->paths->root in the filename and thus does not apply a str_replace?

Thx a lot in advance 🙂 

  • Like 1
Posted

Hey @adrian that works! I added a pull request for that and also added another one to improve dumps when using latte.

The problem here is that when using latte files and adding a {bd('whatever')} in those files tracy actually picks up the compiled cache file and not the source file:

  • source: /site/templates/latte/includes/foo.latte
  • cache: /site/assets/cache/Latte/latte-includes-foo.php

The implementation is kinda hacky and uses rockfrontend's dom tools to parse the html content of the dumps panel and then rewrite it to my needs. I didn't find a better option to modify what tracy puts in its bd() editorlinks output. If you know one let me know!

Posted

Hey @bernhard - I am not sure if this works for all your needs, but you should be able to add to the array of path replacements whenever/wherever you want.

For example:

\Tracy\Debugger::$editorMapping['/assets/cache/Latte/latte-includes-foo.php'] = '/templates/latte/includes/foo.latte';

I feel like you could probably build out all the replacements you need by looping over the files in /assets/cache/Latte/ and replacing the path and filename as needed with some pretty simple logic.

I feel like this should allow you to handle both scenarios in your recent PRs without changes to Tracy.

Sound OK, or am I missing something?

  • Like 1
Posted

@adrian unfortunately I'm lost with this and need some more help 😞 Where would I put this mapping and what would I place as patterns? It feels complicated to me and I'm a bit afraid of doing this for each and every project 😮 

I have a wrong return value in Editor.php on line 49 which throws a bluescreen like this:

nryCJJ7.png

As you can see the path to that file shows /example.com/site/modules/.../Editor.php

The tooltip shows the correct path in the DDEV web container: /public/site/modules...

When I click the link it tries to open that folder in Cursor, but without the needed /public and therefore it does not find the file:

HbjawQQ.png

I'm totally lost and I hope you have an idea?

Posted

Hey @bernhard - you can put it anywhere (so long as Tracy is loaded, which basically excludes config.php, but it works in init.php, ready.php, etc. Or you could put it in any module file that is loaded everywhere.

Another very simple test that adds "/test/" to the path and will work for all editor links.

         \Tracy\Debugger::$editorMapping['/site/templates/'] = '/site/templates/test/';

Can you share what values you've been trying to add to $editorMapping so I can maybe see why it's not working?

  • 2 weeks later...
Posted

Got it working, thank you very much! 🙂 

If anybody else if having trouble, here is how to do it:

First, add this to your ddev config:

web_environment:
  - TRACY_LOCALROOTPATH=$DDEV_APPROOT/

This will add the path of the project root as getenv('TRACY_LOCALROOTPATH') in the web container so that you don't have a hardcoded path in your config.

Next add these mappings in init.php:

\Tracy\Debugger::$editorMapping['/var/www/html/public/'] = getenv('TRACY_LOCALROOTPATH') . 'public/';
\Tracy\Debugger::$editorMapping['/var/www/html/src/'] = getenv('TRACY_LOCALROOTPATH') . 'src/';

 

  • Like 1
  • bernhard changed the title to [solved] IDE links like cursor://file/... not supported for files outside the pw root directory

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...