mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
fix comment newline chomping issue
This commit is contained in:
parent
5e4db62c46
commit
c938a93dea
1 changed files with 12 additions and 4 deletions
|
@ -193,11 +193,18 @@ pub fn spaces_till_end_of_line<'a, E: 'a>(
|
||||||
b'#' => match chomp_line_comment(bytes) {
|
b'#' => match chomp_line_comment(bytes) {
|
||||||
Ok(comment) => {
|
Ok(comment) => {
|
||||||
state.line += 1;
|
state.line += 1;
|
||||||
|
state.column = 0;
|
||||||
|
|
||||||
state.column += col + comment.len() as u16;
|
let width = 1 + comment.len();
|
||||||
state.bytes = &bytes[comment.len()..];
|
if let Some(b'\n') = bytes.get(width) {
|
||||||
|
state.bytes = &bytes[width + 1..];
|
||||||
|
} else {
|
||||||
|
state.bytes = &bytes[width..];
|
||||||
|
}
|
||||||
state.is_indenting = true;
|
state.is_indenting = true;
|
||||||
|
|
||||||
|
dbg!(comment, &state);
|
||||||
|
|
||||||
return Ok((MadeProgress, Some(comment), state));
|
return Ok((MadeProgress, Some(comment), state));
|
||||||
}
|
}
|
||||||
Err(_) => unreachable!("we check the first character is a #"),
|
Err(_) => unreachable!("we check the first character is a #"),
|
||||||
|
@ -214,6 +221,7 @@ pub fn spaces_till_end_of_line<'a, E: 'a>(
|
||||||
None,
|
None,
|
||||||
State {
|
State {
|
||||||
column: col,
|
column: col,
|
||||||
|
bytes,
|
||||||
..state
|
..state
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
@ -275,8 +283,8 @@ where
|
||||||
debug_assert!(u16::MAX - state.indent_col >= spaces as u16);
|
debug_assert!(u16::MAX - state.indent_col >= spaces as u16);
|
||||||
debug_assert!(spaces <= u16::MAX as usize);
|
debug_assert!(spaces <= u16::MAX as usize);
|
||||||
|
|
||||||
// state.indent_col + spaces as u16
|
state.indent_col + spaces as u16
|
||||||
state.indent_col
|
// state.indent_col
|
||||||
} else {
|
} else {
|
||||||
state.indent_col
|
state.indent_col
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue