Skip to content

Commit

Permalink
Fixed issue with diffs containing non matching edited strings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlternateDoctor committed Mar 12, 2024
1 parent 879f303 commit 44153f4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/msbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,13 @@ pub fn edit_string_by_label(msbt_strings: &mut [MSBTString],label: String, strin
ByteOrder::BigEndian => string.encode_utf16().flat_map(|c| c.to_be_bytes()).collect(),
ByteOrder::LittleEndian => string.encode_utf16().flat_map(|c| c.to_le_bytes()).collect(),
};
let vec_index = msbt_strings.iter().position(|s| s.label == label).unwrap();
let old_index = msbt_strings.get(vec_index).unwrap().index;
msbt_strings[vec_index] = MSBTString{ index: old_index, label, string:new_string };
match msbt_strings.iter().position(|s| s.label == label){
Some(index) => {
let old_index = msbt_strings.get(index).unwrap().index;
msbt_strings[index] = MSBTString{ index: old_index, label, string:new_string };
},
None => println!("No label named \"{}\" found!", label),
};
}


Expand Down

0 comments on commit 44153f4

Please sign in to comment.