Trying to properly handle tabs

This commit is contained in:
Pavel Shevaev 2022-08-25 16:05:11 +03:00
parent c96a08808f
commit 1b002fb0ce
1 changed files with 13 additions and 1 deletions

View File

@ -360,7 +360,19 @@ function bhl_clean_cache()
function bhl_show_position($line, $row, array $lines) function bhl_show_position($line, $row, array $lines)
{ {
if($line > 0 && $line <= count($lines)) if($line > 0 && $line <= count($lines))
return $lines[$line-1].str_repeat('-', $row)."^"; {
//handling tabs
$hint = str_replace("\t", " ", $lines[$line-1]);
for($c=0;$c<$row;++$c)
{
if($lines[$line-1][$c] === "\t")
$hint .= "----";
else
$hint .= "-";
}
$hint .= "^";
return $hint;
}
else else
return "??? @($line:$row)"; return "??? @($line:$row)";
} }