Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion harper-comments/src/comment_parsers/lua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Parser for Lua {
for line in source.split(|c| *c == '\n') {
if starts_with_prefix(line) {
tokens.push(Token::new(
Span::new_with_len(chars_traversed, 0),
Span::empty(chars_traversed),
harper_core::TokenKind::Newline(2),
));
chars_traversed += line.len() + 1;
Expand Down
2 changes: 1 addition & 1 deletion harper-core/src/expr/optional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Expr for Optional {
let res = self.inner.run(cursor, tokens, source);

if res.is_none() {
Some(Span::new_with_len(cursor, 0))
Some(Span::empty(cursor))
} else {
res
}
Expand Down
2 changes: 1 addition & 1 deletion harper-core/src/expr/repeating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Repeating {

impl Expr for Repeating {
fn run(&self, mut cursor: usize, tokens: &[Token], source: &[char]) -> Option<Span<Token>> {
let mut window = Span::new_with_len(cursor, 0);
let mut window = Span::empty(cursor);
let mut repetition = 0;

loop {
Expand Down
2 changes: 1 addition & 1 deletion harper-core/src/expr/sequence_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Expr for SequenceExpr {
///
/// If any step returns `None`, the entire expression does as well.
fn run(&self, mut cursor: usize, tokens: &[Token], source: &[char]) -> Option<Span<Token>> {
let mut window = Span::new_with_len(cursor, 0);
let mut window = Span::empty(cursor);

for cur_expr in &self.exprs {
let out = cur_expr.run(cursor, tokens, source)?;
Expand Down
6 changes: 3 additions & 3 deletions harper-core/src/parsers/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ impl Parser for Markdown {
}
pulldown_cmark::Event::Start(pulldown_cmark::Tag::List(v)) => {
tokens.push(Token {
span: Span::new_with_len(span_start, 0),
span: Span::empty(span_start),
kind: TokenKind::Newline(2),
});
stack.push(pulldown_cmark::Tag::List(v));
}
pulldown_cmark::Event::Start(tag) => {
if matches!(tag, pulldown_cmark::Tag::Heading { .. }) {
tokens.push(Token {
span: Span::new_with_len(span_start, 0),
span: Span::empty(span_start),
kind: TokenKind::HeadingStart,
});
}
Expand All @@ -225,7 +225,7 @@ impl Parser for Markdown {
// position of the previous token's last character. This ensures the
// paragraph break is placed at the end of the content, not its beginning.
// For more info, see: https://github.com/Automattic/harper/pull/1239.
span: Span::new_with_len(tokens.last().map_or(0, |last| last.span.end), 0),
span: Span::empty(tokens.last().map_or(0, |last| last.span.end)),
kind: TokenKind::ParagraphBreak,
});
stack.pop();
Expand Down
2 changes: 1 addition & 1 deletion harper-core/src/parsers/oops_all_headings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<P: Parser + 'static> Parser for OopsAllHeadings<P> {
&& iter.peek().is_some_and(|t| !t.kind.is_heading_start())
{
Some(Token {
span: Span::new_with_len(tok.span.end, 0),
span: Span::empty(tok.span.end),
kind: TokenKind::HeadingStart,
})
} else {
Expand Down
2 changes: 1 addition & 1 deletion harper-core/src/parsers/org_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl Parser for OrgMode {

// Add paragraph break after header
tokens.push(Token {
span: Span::new_with_len(line_end.saturating_sub(1), 0),
span: Span::empty(line_end.saturating_sub(1)),
kind: TokenKind::ParagraphBreak,
});

Expand Down