Skip to content

Commit

Permalink
ensure all diagnostics start with 1 (#894)
Browse files Browse the repository at this point in the history
  • Loading branch information
rochala authored Jul 4, 2023
1 parent bc817f0 commit 3f3a620
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ object CodeEditor {
val errors = props.compilationInfos
.filter(prob => prob.line.isDefined && prob.line.get <= doc.lines)
.map(problem => {
val line = problem.line.get
val line = problem.line.get max 1
val lineInfo = doc.line(line)

Diagnostic(lineInfo.from, HTMLFormatter.format(problem.message), parseSeverity(problem.severity), lineInfo.to)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class OutputExtractor(getScalaJsContent: () => Option[String],
val problems = extract[List[Problem]](line)

val problemsWithOffset = problems.map {
_.map(problem => problem.copy(line = problem.line.map(_ + lineOffset)))
_.map(problem => problem.copy(line = problem.line.map(lineNumber => (lineNumber + lineOffset) max 1)))
}

def annoying(in: Problem): Boolean = {
Expand All @@ -144,7 +144,9 @@ class OutputExtractor(getScalaJsContent: () => Option[String],
extract[RuntimeErrorWrap](line).flatMap {
_.error.map { error =>
val noStackTraceError = if (error.message.contains("No main class detected.")) error.copy(fullStack = "") else error
val errorWithOffset = noStackTraceError.copy(line = noStackTraceError.line.map(_ + lineOffset))
val errorWithOffset = noStackTraceError.copy(
line = noStackTraceError.line.map(lineNumber => (lineNumber + lineOffset) max 1)
)
errorWithOffset
}
}
Expand Down

0 comments on commit 3f3a620

Please sign in to comment.