Skip to content

Conversation

cseknowledge
Copy link
Contributor

Add support for Brackets editor in ResolvesDumpSource. While Brackets development has ceased, it remains in active use by many developers.

@taylorotwell
Copy link
Member

Not adding any more.

@rodrigopedra
Copy link
Contributor

@cseknowledge you can add this to your ./config/app.php file:

<?php

return [
    // other configs

    'editor' => [
        'name' => env('EDITOR_NAME'),
        'href' => env('EDITOR_HREF'),
    ],

];

Then in your .env file you can add:

EDITOR_HREF=brackets://open?url=file://{file}&line={line}

For editors that Laravel has built-in support, you only need to set EDITOR_NAME.

For other editors, you only need to set EDITOR_HREF.

Actually, if config('app.editor.href') is defined, then Laravel will use that and ignore the value of config('app.editor.name').

This way, if there are multiple persons in your team using different editors, each one can use their preferred editor.

Reference:

/**
* Resolve the source href, if possible.
*
* @param string $file
* @param int|null $line
* @return string|null
*/
protected function resolveSourceHref($file, $line)
{
try {
$editor = config('app.editor');
} catch (Throwable) {
// ..
}
if (! isset($editor)) {
return;
}
$href = is_array($editor) && isset($editor['href'])
? $editor['href']
: ($this->editorHrefs[$editor['name'] ?? $editor] ?? sprintf('%s://open?file={file}&line={line}', $editor['name'] ?? $editor));
if ($basePath = $editor['base_path'] ?? false) {
$file = str_replace($this->basePath, $basePath, $file);
}
return str_replace(
['{file}', '{line}'],
[$file, is_null($line) ? 1 : $line],
$href,
);
}

@cseknowledge
Copy link
Contributor Author

@rodrigopedra Thanks for your valuable comments.

Sign up for free to 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.

3 participants