Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Feb 20, 2024
1 parent 916af03 commit e83e14b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
6 changes: 5 additions & 1 deletion sugarloaf/src/sugarloaf/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub struct SugarLine {
// https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b3face22f8c64b25803fa213be6a858f

// inner: [Sugar; SUGAR_LINE_MAX_CONTENT_SIZE],
// pub len: usize,
pub len: usize,
inner: Vec<Sugar>,
first_non_default: usize,
last_non_default: usize,
Expand Down Expand Up @@ -166,6 +166,7 @@ impl Default for SugarLine {
fn default() -> Self {
Self {
// hash: 00000000000000,
len: 0,
last_non_default: 0,
first_non_default: 0,
non_default_count: 0,
Expand Down Expand Up @@ -209,6 +210,7 @@ impl SugarLine {
let len = self.inner.len();

if len > 0 && equal_without_consider_repeat(&self.inner[len - 1], sugar) {
self.len += 1;
self.inner[len - 1].repeated += 1;
return;
}
Expand All @@ -225,6 +227,8 @@ impl SugarLine {

self.non_default_count += 1;
}

self.len += 1;
}

#[inline]
Expand Down
14 changes: 8 additions & 6 deletions sugarloaf/src/sugarloaf/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ impl SugarState {
// then current will flip with next and will try to obtain
// the dimensions.

println!("{:?}", self.current_has_empty_dimensions());

if self.latest_change != SugarTreeDiff::LayoutIsDifferent
// || !self.current_has_empty_dimensions()
{
Expand Down Expand Up @@ -292,13 +290,10 @@ impl SugarState {
std::mem::swap(&mut self.current, &mut self.next);

if self.level.is_advanced() {
self.compositors
.advanced
.calculate_dimensions(&self.current);
self.compositors.advanced.calculate_dimensions(&self.next);
}

self.compositors.elementary.set_should_resize();
self.reset_next();
return;
}

Expand All @@ -323,7 +318,12 @@ impl SugarState {
should_clean_blocks = true;
should_update = true;
}
SugarTreeDiff::ColumnsLengthIsDifferent(_different) => {
println!("ColumnsLengthIsDifferent");
should_update = true;
}
SugarTreeDiff::Changes(_changes) => {
println!("Changes");
should_update = true;
}
_ => {
Expand All @@ -332,6 +332,8 @@ impl SugarState {
}
}

println!("{:?}", self.latest_change);

if should_update {
std::mem::swap(&mut self.current, &mut self.next);

Expand Down
11 changes: 10 additions & 1 deletion sugarloaf/src/sugarloaf/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,18 @@ impl SugarTree {
for line_number in 0..current_len {
let line: &SugarLine = &self.lines[line_number];
let next_line: &SugarLine = &next.lines[line_number];

// .len stands for column size and .len() sugar elements
// this needs to be differenciated
// if line.len != next_line.len {
// return SugarTreeDiff::ColumnsLengthIsDifferent(
// line.len as i32 - next_line.len as i32,
// );
// }

if line.len() != next_line.len() {
return SugarTreeDiff::ColumnsLengthIsDifferent(
line.len() as i32 - next_line.len() as i32,
line.len as i32 - next_line.len as i32,
);
}

Expand Down

0 comments on commit e83e14b

Please sign in to comment.