Increment input_column
correctly when inside the leading tab
This commit is contained in:
parent
5c1f82ae3d
commit
813f722925
1 changed files with 6 additions and 3 deletions
|
@ -467,6 +467,7 @@ impl<'a> Iterator for TabChunks<'a> {
|
||||||
if self.skip_leading_tab {
|
if self.skip_leading_tab {
|
||||||
self.chunk.text = &self.chunk.text[1..];
|
self.chunk.text = &self.chunk.text[1..];
|
||||||
self.skip_leading_tab = false;
|
self.skip_leading_tab = false;
|
||||||
|
self.input_column += 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
|
@ -500,7 +501,7 @@ impl<'a> Iterator for TabChunks<'a> {
|
||||||
self.input_column += 1;
|
self.input_column += 1;
|
||||||
self.output_position = next_output_position;
|
self.output_position = next_output_position;
|
||||||
return Some(Chunk {
|
return Some(Chunk {
|
||||||
text: &SPACES[0..len as usize],
|
text: &SPACES[..len as usize],
|
||||||
..self.chunk
|
..self.chunk
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -512,7 +513,9 @@ impl<'a> Iterator for TabChunks<'a> {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.column += 1;
|
self.column += 1;
|
||||||
self.input_column += c.len_utf8() as u32;
|
if !self.skip_leading_tab {
|
||||||
|
self.input_column += c.len_utf8() as u32;
|
||||||
|
}
|
||||||
self.output_position.column += c.len_utf8() as u32;
|
self.output_position.column += c.len_utf8() as u32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -659,11 +662,11 @@ mod tests {
|
||||||
.collect::<String>();
|
.collect::<String>();
|
||||||
let expected_summary = TextSummary::from(expected_text.as_str());
|
let expected_summary = TextSummary::from(expected_text.as_str());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_text,
|
|
||||||
tabs_snapshot
|
tabs_snapshot
|
||||||
.chunks(start..end, false, None)
|
.chunks(start..end, false, None)
|
||||||
.map(|c| c.text)
|
.map(|c| c.text)
|
||||||
.collect::<String>(),
|
.collect::<String>(),
|
||||||
|
expected_text,
|
||||||
"chunks({:?}..{:?})",
|
"chunks({:?}..{:?})",
|
||||||
start,
|
start,
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue