Merge pull request #3092 from rivenhk/b_2885

added formatting when source snippets is too long
This commit is contained in:
chriseth
2017-10-23 10:54:52 +02:00
committed by GitHub
2 changed files with 16 additions and 0 deletions
@@ -49,6 +49,21 @@ void SourceReferenceFormatter::printSourceLocation(
if (startLine == endLine)
{
string line = scanner.lineAtPosition(_location->start);
int locationLength = endColumn - startColumn;
if (locationLength > 150)
{
line = line.substr(0, startColumn + 35) + " ... " + line.substr(endColumn - 35);
endColumn = startColumn + 75;
locationLength = 75;
}
if (line.length() > 150)
{
line = " ... " + line.substr(startColumn, locationLength) + " ... ";
startColumn = 5;
endColumn = startColumn + locationLength;
}
_stream << line << endl;
for_each(
line.cbegin(),