Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor align_selection using kakoune logic #1675

Merged
merged 2 commits into from
Mar 3, 2022
Merged

refactor align_selection using kakoune logic #1675

merged 2 commits into from
Mar 3, 2022

Conversation

QiBaobin
Copy link
Contributor

column_widths.push(vec![(l1, cursor)]);
}
}
let mut max_curs = vec![];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut max_curs = vec![];
let mut max_curs = Vec::with_capacity(column_widths.len())

Comment on lines 812 to 814
for item in column_widths[i].iter_mut() {
pads.insert(item.0, max_cur - item.1);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for item in column_widths[i].iter_mut() {
pads.insert(item.0, max_cur - item.1);
}
for (line_start, cursor) in &column_widths[i] {
pads.insert(line_start, max_cur - cursor);
}

.fold(0, |max, &(_, cur)| max.max(cur));
max_curs.push(max_cur);

let mut pads = std::collections::HashMap::new();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut pads = std::collections::HashMap::new();
let mut pads = std::collections::HashMap::with_capacity(column_widths[i].len());

Comment on lines 806 to 808
let max_cur = column_widths[i]
.iter()
.fold(0, |max, &(_, cur)| max.max(cur));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.iter().map(|(_, cur)| cur).max()?

@archseer archseer merged commit c0b86af into helix-editor:master Mar 3, 2022
@archseer
Copy link
Member

archseer commented Mar 3, 2022

Thanks! 🎉

@archseer archseer mentioned this pull request Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants