@@ -201,21 +201,28 @@ function parseYAMLSource(
201201
202202 root . errors . forEach ( ( error ) => {
203203 const severity = error . isWarning ? Severity . WARNING : Severity . ERROR ;
204- const endPos = getLineEndPosition ( error . mark . line + 1 , projectSource ) ;
204+
205+ // Errors reported do not have an end, only a start. We just choose the line end as the end.
206+ // While there is a toLineEnd boolean, we ignore this, because what else would we really do?
207+ let location : MessageLocation ;
208+ if ( error . mark . position < projectSource . body . length ) {
209+ location = new MessageLocation (
210+ projectSource ,
211+ new SourcePosition ( error . mark . position , error . mark . line + 1 , error . mark . column + 1 ) ,
212+ getLineEndPosition ( error . mark . line + 1 , projectSource ) ,
213+ ) ;
214+ } else {
215+ // This is an exception: An error can be reported at the EOL. Calculating the EOL would not work
216+ // -> just report the error at the last character
217+ location = new MessageLocation (
218+ projectSource ,
219+ projectSource . body . length - 1 ,
220+ projectSource . body . length ,
221+ ) ;
222+ }
223+
205224 validationContext . addMessage (
206- new ValidationMessage ( {
207- severity,
208- message : error . reason ,
209- location : new MessageLocation (
210- projectSource ,
211- new SourcePosition (
212- error . mark . position ,
213- error . mark . line + 1 ,
214- error . mark . column + 1 ,
215- ) ,
216- endPos ,
217- ) ,
218- } ) ,
225+ new ValidationMessage ( { severity, message : error . reason , location } ) ,
219226 ) ;
220227 } ) ;
221228
0 commit comments