Skip to content

Commit 4a8b6ed

Browse files
committed
highlight entire line for csv errors
1 parent 94554f8 commit 4a8b6ed

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

espflash/src/error.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,16 @@ impl PartitionTableError {
250250
let snip_end =
251251
SourceOffset::from_location(&source, err_pos.line().saturating_add(2) as usize, 0);
252252
let snip = SourceSpan::new(snip_start, (snip_end.offset() - snip_start.offset()).into());
253-
let err_span = SourceSpan::new(pos_to_offset(err_pos), 0.into());
253+
254+
// since csv doesn't give us the position in the line the error occurs, we highlight the entire line
255+
let line_length = (source
256+
.lines()
257+
.nth(err_pos.line() as usize - 1)
258+
.unwrap()
259+
.len()
260+
- 1)
261+
.into();
262+
let err_span = SourceSpan::new(pos_to_offset(err_pos), line_length);
254263

255264
PartitionTableError {
256265
source,

0 commit comments

Comments
 (0)