Fix lint & tests
This commit is contained in:
parent
4c77a0360e
commit
b0ad819ac6
4 changed files with 23 additions and 10 deletions
|
|
@ -371,7 +371,9 @@ where
|
|||
|
||||
Operation::Insert { text, .. } => {
|
||||
if let Some(prev_length) = previous_equal {
|
||||
result.push(NumberOrString::Number(prev_length as i64));
|
||||
result.push(NumberOrString::Number(
|
||||
i64::try_from(prev_length).unwrap_or(i64::MAX),
|
||||
));
|
||||
previous_equal = None;
|
||||
}
|
||||
|
||||
|
|
@ -387,17 +389,22 @@ where
|
|||
..
|
||||
} => {
|
||||
if let Some(prev_length) = previous_equal {
|
||||
result.push(NumberOrString::Number(prev_length as i64));
|
||||
result.push(NumberOrString::Number(
|
||||
i64::try_from(prev_length).unwrap_or(i64::MAX),
|
||||
));
|
||||
previous_equal = None;
|
||||
}
|
||||
|
||||
result.push(NumberOrString::Number(-(*deleted_character_count as i64)));
|
||||
let count = i64::try_from(*deleted_character_count).unwrap_or(i64::MAX);
|
||||
result.push(NumberOrString::Number(-count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(prev_length) = previous_equal {
|
||||
result.push(NumberOrString::Number(prev_length as i64));
|
||||
result.push(NumberOrString::Number(
|
||||
i64::try_from(prev_length).unwrap_or(i64::MAX),
|
||||
));
|
||||
}
|
||||
|
||||
result
|
||||
|
|
@ -417,7 +424,7 @@ where
|
|||
match simple_operation {
|
||||
NumberOrString::Number(length) => {
|
||||
if length >= 0 {
|
||||
let length = length as usize;
|
||||
let length = usize::try_from(length).unwrap_or(usize::MAX);
|
||||
let original_characters: String =
|
||||
original_text.chars().skip(order).take(length).collect();
|
||||
|
||||
|
|
@ -428,7 +435,7 @@ where
|
|||
order += token.get_original_length();
|
||||
}
|
||||
} else {
|
||||
let length = -length as usize;
|
||||
let length = usize::try_from(-length).unwrap_or(usize::MAX);
|
||||
operations.push(Operation::create_delete(order, length));
|
||||
order += length;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ impl TextWithCursorsAndHistory {
|
|||
/// Returns the UTF8 parsed string if it's a text, or `None` if it's likely
|
||||
/// binary.
|
||||
#[must_use]
|
||||
pub fn string_or_nothing(data: &[u8]) -> Option<String> {
|
||||
fn string_or_nothing(data: &[u8]) -> Option<String> {
|
||||
if data.contains(&0) {
|
||||
// Even though the NUL character is valid in UTF-8, it's highly suspicious in
|
||||
// human-readable text.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue