1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00

columnRange -> column

This commit is contained in:
Ben Burdette 2020-04-07 14:36:32 -06:00
parent 55c96b64e4
commit 00c507cc52
2 changed files with 9 additions and 18 deletions

View file

@ -46,8 +46,8 @@ ErrorInfo ErrorInfo::ProgramEI(ErrLevel level,
string showErrLine(const ErrLine &errLine)
{
if (errLine.columnRange.has_value()) {
return (format("(%1%:%2%)") % errLine.lineNumber % errLine.columnRange->start).str();
if (errLine.column > 0) {
return (format("(%1%:%2%)") % errLine.lineNumber % errLine.column).str();
} else {
return (format("(%1%)") % errLine.lineNumber).str();
};
@ -74,18 +74,14 @@ void printCodeLines(const string &prefix, const NixCode &nixCode)
<< std::endl;
// error arrows for the column range.
if (nixCode.errLine->columnRange.has_value()) {
int start = nixCode.errLine->columnRange->start;
if (nixCode.errLine->column > 0) {
int start = nixCode.errLine->column;
std::string spaces;
for (int i = 0; i < start; ++i) {
spaces.append(" ");
}
int len = nixCode.errLine->columnRange->len;
std::string arrows;
for (int i = 0; i < len; ++i) {
arrows.append("^");
}
std::string arrows("^");
std::cout << format("%1% |%2%" ANSI_RED "%3%" ANSI_NORMAL) % prefix % spaces % arrows << std::endl;
}