diff --git a/src/Whoops/Exception/Frame.php b/src/Whoops/Exception/Frame.php index 5aecd37..dc1ae93 100644 --- a/src/Whoops/Exception/Frame.php +++ b/src/Whoops/Exception/Frame.php @@ -58,7 +58,9 @@ class Frame implements Serializable if ($shortened && is_string($file)) { // Replace the part of the path that all frames have in common, and add 'soft hyphens' for smoother line-breaks. $dirname = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__)))))); - $file = str_replace($dirname, "…", $file); + if ($dirname !== '/') { + $file = str_replace($dirname, "…", $file); + } $file = str_replace("/", "/­", $file); } diff --git a/src/Whoops/Resources/css/whoops.base.css b/src/Whoops/Resources/css/whoops.base.css index 7c11d52..4c1ef71 100644 --- a/src/Whoops/Resources/css/whoops.base.css +++ b/src/Whoops/Resources/css/whoops.base.css @@ -171,7 +171,6 @@ header { .frame-file { font-family: "Inconsolata", "Fira Mono", "Source Code Pro", Monaco, Consolas, "Lucida Console", monospace; - word-wrap: break-word; color: #a29d9d; } @@ -257,6 +256,10 @@ header { color: white; } +.delimiter { + display: inline-block; +} + .data-table-container label { font-size: 16px; color: #303030; diff --git a/src/Whoops/Resources/views/frame_code.html.php b/src/Whoops/Resources/views/frame_code.html.php index 9bd1973..7505087 100644 --- a/src/Whoops/Resources/views/frame_code.html.php +++ b/src/Whoops/Resources/views/frame_code.html.php @@ -10,10 +10,10 @@ getEditorHref($filePath, (int) $line)): ?> Open: getEditorAjax($filePath, (int) $line) ? ' data-ajax' : '') ?>> - escape($filePath ?: '<#unknown>') ?> + breakOnDelimiter('/', $tpl->escape($filePath ?: '<#unknown>')) ?> - escape($filePath ?: '<#unknown>') ?> + breakOnDelimiter('/', $tpl->escape($filePath ?: '<#unknown>')) ?> " id="frame-line-">
- escape($frame->getClass() ?: '') ?> - escape($frame->getFunction() ?: '') ?> + breakOnDelimiter('\\', $tpl->escape($frame->getClass() ?: '')) ?> + breakOnDelimiter('\\', $tpl->escape($frame->getFunction() ?: '')) ?>
- - getFile(true) ?: '<#unknown>') ?>getLine() ?> - + diff --git a/src/Whoops/Util/TemplateHelper.php b/src/Whoops/Util/TemplateHelper.php index 0b0d07f..aadd0ab 100644 --- a/src/Whoops/Util/TemplateHelper.php +++ b/src/Whoops/Util/TemplateHelper.php @@ -72,6 +72,39 @@ class TemplateHelper ); } + /** + * Makes sure that the given string breaks on the delimiter. + * + * @param string $delimiter + * @param string $s + * @return string + */ + public function breakOnDelimiter($delimiter, $s) + { + $parts = explode($delimiter, $s); + foreach ($parts as &$part) { + $part = '
' . $part . '
'; + } + + return implode($delimiter, $parts); + } + + /** + * Replace the part of the path that all files have in common. + * + * @param string $path + * @return string + */ + public function shorten($path) + { + $dirname = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__)))))); + if ($dirname != "/") { + $path = str_replace($dirname, '…', $path); + } + + return $path; + } + private function getDumper() { if (!$this->htmlDumper && class_exists('Symfony\Component\VarDumper\Cloner\VarCloner')) {