dev: drop if_chain and collapse if statements (#2097)
Some checks are pending
tinymist::auto_tag / auto-tag (push) Waiting to run
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run

This commit is contained in:
QuadnucYard 2025-09-01 16:46:54 +08:00 committed by GitHub
parent 1c9db1ce69
commit ce447185d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 520 additions and 545 deletions

View file

@ -349,18 +349,19 @@ impl Tokenizer {
.map(|token_type| Token::new(token_type, modifiers, range.clone()));
// Push start
if let Some(prev_token) = self.token.as_mut() {
if !prev_token.range.is_empty() && prev_token.range.start < range.start {
let end = prev_token.range.end.min(range.start);
let sliced = Token {
token_type: prev_token.token_type,
modifiers: prev_token.modifiers,
range: prev_token.range.start..end,
};
// Slice the previous token
prev_token.range.start = end;
self.push(sliced);
}
if let Some(prev_token) = self.token.as_mut()
&& !prev_token.range.is_empty()
&& prev_token.range.start < range.start
{
let end = prev_token.range.end.min(range.start);
let sliced = Token {
token_type: prev_token.token_type,
modifiers: prev_token.modifiers,
range: prev_token.range.start..end,
};
// Slice the previous token
prev_token.range.start = end;
self.push(sliced);
}
if !is_leaf {
@ -372,14 +373,14 @@ impl Tokenizer {
}
// Push end
if let Some(token) = token.clone() {
if !token.range.is_empty() {
// Slice the previous token
if let Some(prev_token) = self.token.as_mut() {
prev_token.range.start = token.range.end;
}
self.push(token);
if let Some(token) = token.clone()
&& !token.range.is_empty()
{
// Slice the previous token
if let Some(prev_token) = self.token.as_mut() {
prev_token.range.start = token.range.end;
}
self.push(token);
}
}