Fixed nasty bug in reformatting code.
It was not actually reformatting things...
This commit is contained in:
parent
7b87db4e41
commit
afa1a8f67c
|
@ -210,7 +210,7 @@ impl<T: LineFormatter> Buffer<T> {
|
||||||
|
|
||||||
/// Runs the formatter on all of the text. Should be run whenever the
|
/// Runs the formatter on all of the text. Should be run whenever the
|
||||||
/// formatter has been changed.
|
/// formatter has been changed.
|
||||||
pub fn reformat<'a>(&'a mut self) {
|
pub fn reformat(&mut self) {
|
||||||
self.text.reformat_recursive(&self.formatter);
|
self.text.reformat_recursive(&self.formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,12 +196,17 @@ impl BufferNode {
|
||||||
|
|
||||||
|
|
||||||
pub fn reformat_recursive<T: LineFormatter>(&mut self, f: &T) {
|
pub fn reformat_recursive<T: LineFormatter>(&mut self, f: &T) {
|
||||||
if let BufferNodeData::Branch(ref mut left, ref mut right) = self.data {
|
match self.data {
|
||||||
left.update_stats(f);
|
BufferNodeData::Branch(ref mut left, ref mut right) => {
|
||||||
right.update_stats(f);
|
left.reformat_recursive(f);
|
||||||
}
|
right.reformat_recursive(f);
|
||||||
|
self.vis_dim = ((left.vis_dim.0 + right.vis_dim.0), max(left.vis_dim.1, right.vis_dim.1));
|
||||||
|
},
|
||||||
|
|
||||||
self.update_stats(f);
|
BufferNodeData::Leaf(ref line) => {
|
||||||
|
self.vis_dim = f.dimensions(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ impl TermUI {
|
||||||
self.width = w as usize;
|
self.width = w as usize;
|
||||||
self.height = h as usize;
|
self.height = h as usize;
|
||||||
self.editor.update_dim(self.height-1, self.width);
|
self.editor.update_dim(self.height-1, self.width);
|
||||||
self.editor.buffer.formatter.wrap_width = w as usize;
|
self.editor.buffer.formatter.wrap_width = self.width;
|
||||||
self.editor.buffer.reformat();
|
self.editor.buffer.reformat();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user