big brained it, labels work now
This commit is contained in:
parent
44d508a15a
commit
cac3721605
1 changed files with 4 additions and 2 deletions
|
@ -24,10 +24,12 @@ pub fn split_u16(number: u16) -> (u8, u8) {
|
|||
pub fn detect_labels(mut chunks: Vec<String>) -> (Vec<String>, Vec<Label>) {
|
||||
let mut stripped_chunks: Vec<String> = vec![];
|
||||
let mut labels: Vec<Label> = vec![];
|
||||
let mut encountered_labels: usize = 0; // I had a feeling of serendipity when I realised what was screwing with labels.
|
||||
|
||||
for (index, element) in chunks.iter().enumerate() {
|
||||
if element.chars().next() == Some(';') {
|
||||
println!("{}", index);
|
||||
let label = Label { label: element.replace(";","").to_string(), index: index*4 };
|
||||
let label = Label { label: element.replace(";","").to_string(), index: (index - encountered_labels) * 4 };
|
||||
encountered_labels = encountered_labels + 1;
|
||||
labels.push(label);
|
||||
} else {
|
||||
stripped_chunks.push(element.to_string());
|
||||
|
|
Reference in a new issue