Allow set_align to clear the alignment by setting it to None
This commit is contained in:
parent
45f6474a74
commit
fff8389bbf
2 changed files with 6 additions and 5 deletions
|
|
@ -334,9 +334,9 @@ fn update_alignment<'a, T: Edit<'a>>(editor: &mut T, align: Align) {
|
|||
std::cmp::Ordering::Equal => (current_line, current_line),
|
||||
};
|
||||
for line in editor.buffer_mut().lines[start..=end].iter_mut() {
|
||||
line.set_align(align);
|
||||
line.set_align(Some(align));
|
||||
}
|
||||
} else if let Some(line) = editor.buffer_mut().lines.get_mut(current_line) {
|
||||
line.set_align(align);
|
||||
line.set_align(Some(align));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,10 +104,11 @@ impl BufferLine {
|
|||
/// Set the text alignment
|
||||
///
|
||||
/// Will reset shape and layout if it differs from current alignment.
|
||||
/// Setting to None will use `Align::Right` for RTL lines, and `Align::Left` for LTR lines.
|
||||
/// Returns true if the line was reset
|
||||
pub fn set_align(&mut self, align: Align) -> bool {
|
||||
if Some(align) != self.align {
|
||||
self.align = Some(align);
|
||||
pub fn set_align(&mut self, align: Option<Align>) -> bool {
|
||||
if align != self.align {
|
||||
self.align = align;
|
||||
self.reset_layout();
|
||||
true
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue