Skip to content

Commit 7613076

Browse files
committed
compiler now uses the markup diag position where possible.
While this is mostly working it isn't really the best and will have to rework how markup diagnostics is done if we want better diagnostics. Something for the future.
1 parent 1e76483 commit 7613076

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4646
- Comments in headers are now correctly being determined
4747
- in predefined headers like `title` this fixes a parsing error
4848
- in free-form headers this fixes comments being part of the value of the header
49+
- fixed a crash in some weeeeeeird markup structures
4950
5051
### Removed
5152

YarnSpinner.Compiler/Compiler.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,27 @@ public static CompilationResult Compile(CompilationJob compilationJob)
254254
var result = lineParser.ParseStringAndIncludeMarkupDiagnostics(line.Value.text, System.Globalization.CultureInfo.InvariantCulture.TwoLetterISOLanguageName);
255255
foreach (var diag in result.diagnostics)
256256
{
257-
// TODO: Markup diagnostic column information is currently
258-
// not set; default the range to the entirety of the line
259-
// for now
260-
var range = new Range(
261-
line.Value.lineNumber - 1,
262-
0,
263-
line.Value.lineNumber - 1,
264-
line.Value.text.Length
265-
);
257+
// TODO: change how markup presents it's diagnostics so we can get more useful diagnostics
258+
// if the position is -1 we want the whole line, otherwise we want to just say where the problem began
259+
Range range;
260+
if (diag.Column == -1)
261+
{
262+
range = new Range(
263+
line.Value.lineNumber - 1,
264+
0,
265+
line.Value.lineNumber - 1,
266+
line.Value.text.Length
267+
);
268+
}
269+
else
270+
{
271+
range = new Range(
272+
line.Value.lineNumber - 1,
273+
diag.Column,
274+
line.Value.lineNumber - 1,
275+
diag.Column
276+
);
277+
}
266278
diagnostics.Add(DiagnosticDescriptor.MarkupFailedToParse.Create(line.Value.fileName, range, diag.Message));
267279
}
268280
}

0 commit comments

Comments
 (0)