diff --git a/crates/turbopack-core/src/issue/mod.rs b/crates/turbopack-core/src/issue/mod.rs index 30e6123eac468..78ac64b7dea67 100644 --- a/crates/turbopack-core/src/issue/mod.rs +++ b/crates/turbopack-core/src/issue/mod.rs @@ -431,6 +431,7 @@ pub struct IssueSource { range: Option>, } +/// The end position is the first character after the range #[turbo_tasks::value] #[derive(Clone, Debug)] enum SourceRange { diff --git a/crates/turbopack-mdx/src/lib.rs b/crates/turbopack-mdx/src/lib.rs index 37097793621aa..041a47e1e04ca 100644 --- a/crates/turbopack-mdx/src/lib.rs +++ b/crates/turbopack-mdx/src/lib.rs @@ -189,20 +189,22 @@ impl MdxTransformedAsset { Err(err) => { let loc = Vc::cell(err.place.map(|p| { let (start, end) = match *p { + // markdown's positions are 1-indexed, SourcePos is 0-indexed. + // Both end positions point to the first character after the range markdown::message::Place::Position(p) => ( SourcePos { - line: p.start.line, - column: p.start.column, + line: p.start.line - 1, + column: p.start.column - 1, }, SourcePos { - line: p.end.line, - column: p.end.column, + line: p.end.line - 1, + column: p.end.column - 1, }, ), markdown::message::Place::Point(p) => { let p = SourcePos { - line: p.line, - column: p.column, + line: p.line - 1, + column: p.column - 1, }; (p, p) }