mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
[red-knot] Report line numbers in mdtest relative to the markdown file, not the test snippet (#13804)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com> Co-authored-by: Micha Reiser <micha@reiser.io> Co-authored-by: Carl Meyer <carl@oddbird.net>
This commit is contained in:
parent
9d102799f9
commit
cd6c937194
4 changed files with 130 additions and 53 deletions
|
@ -26,6 +26,16 @@ impl<'a> Cursor<'a> {
|
|||
self.chars.clone()
|
||||
}
|
||||
|
||||
/// Returns the remaining input as byte slice.
|
||||
pub fn as_bytes(&self) -> &'a [u8] {
|
||||
self.as_str().as_bytes()
|
||||
}
|
||||
|
||||
/// Returns the remaining input as string slice.
|
||||
pub fn as_str(&self) -> &'a str {
|
||||
self.chars.as_str()
|
||||
}
|
||||
|
||||
/// Peeks the next character from the input stream without consuming it.
|
||||
/// Returns [`EOF_CHAR`] if the file is at the end of the file.
|
||||
pub fn first(&self) -> char {
|
||||
|
@ -110,4 +120,13 @@ impl<'a> Cursor<'a> {
|
|||
self.bump_back();
|
||||
}
|
||||
}
|
||||
|
||||
/// Skips the next `count` bytes.
|
||||
///
|
||||
/// ## Panics
|
||||
/// - If `count` is larger than the remaining bytes in the input stream.
|
||||
/// - If `count` indexes into a multi-byte character.
|
||||
pub fn skip_bytes(&mut self, count: usize) {
|
||||
self.chars = self.chars.as_str()[count..].chars();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue