Skip to content

Commit

Permalink
Helpers::editorLink() improved file name truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 24, 2021
1 parent 362f6fa commit 5dcff41
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Tracy/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ public static function editorLink(string $file, int $line = null): string
{
$file = strtr($origFile = $file, Debugger::$editorMapping);
if ($editor = self::editorUri($origFile, $line)) {
$file = strtr($file, '\\', '/');
if (preg_match('#(^[a-z]:)?/.{1,40}$#i', $file, $m) && strlen($file) > strlen($m[0])) {
$file = '...' . $m[0];
$parts = explode('/', strtr($file, '\\', '/'));
$file = array_pop($parts);
while ($parts && strlen($file) < 42) {
$file = array_pop($parts) . '/' . $file;
}
$file = ($parts ? '.../' : '') . $file;
$file = strtr($file, '/', DIRECTORY_SEPARATOR);

return self::formatHtml(
'<a href="%" title="%" class="tracy-editor">%<b>%</b>%</a>',
$editor,
Expand Down

0 comments on commit 5dcff41

Please sign in to comment.