better indentation errors (use original location for error)

This commit is contained in:
Folkert 2021-02-12 13:47:56 +01:00
parent 21efa8cd71
commit 19d3e43f09
5 changed files with 241 additions and 38 deletions

View file

@ -444,6 +444,9 @@ where
let mut state = state;
let mut any_newlines = false;
let start_row = original_state.line;
let start_col = original_state.column;
let start_bytes_len = state.bytes.len();
while !state.bytes.is_empty() {
@ -491,7 +494,13 @@ where
let progress =
Progress::from_lengths(start_bytes_len, state.bytes.len());
state = state
.check_indent_e(arena, min_indent, indent_problem)
.check_indent_e(
arena,
min_indent,
indent_problem,
start_row,
start_col,
)
.map_err(|(fail, _)| {
(progress, fail, original_state.clone())
})?
@ -523,7 +532,13 @@ where
);
if any_newlines {
state = state
.check_indent_e(arena, min_indent, indent_problem)
.check_indent_e(
arena,
min_indent,
indent_problem,
start_row,
start_col,
)
.map_err(|(fail, _)| {
(progress, fail, original_state.clone())
})?;
@ -692,7 +707,13 @@ where
progress,
space_slice,
state
.check_indent_e(arena, min_indent, indent_problem)
.check_indent_e(
arena,
min_indent,
indent_problem,
start_row,
start_col,
)
.map_err(|(fail, _)| (progress, fail, original_state))?,
));
}
@ -720,7 +741,7 @@ where
let progress = Progress::from_lengths(start_bytes_len, state.bytes.len());
if any_newlines {
state = state
.check_indent_e(arena, min_indent, indent_problem)
.check_indent_e(arena, min_indent, indent_problem, start_row, start_col)
.map_err(|(fail, _)| (progress, fail, original_state))?;
}