Fixed nasty bug in reformatting code.

It was not actually reformatting things...
This commit is contained in:
Nathan Vegdahl 2015-01-31 13:41:41 -08:00
parent 7b87db4e41
commit afa1a8f67c
3 changed files with 12 additions and 7 deletions

View File

@ -210,7 +210,7 @@ impl<T: LineFormatter> Buffer<T> {
/// Runs the formatter on all of the text. Should be run whenever the
/// formatter has been changed.
pub fn reformat<'a>(&'a mut self) {
pub fn reformat(&mut self) {
self.text.reformat_recursive(&self.formatter);
}

View File

@ -196,12 +196,17 @@ impl BufferNode {
pub fn reformat_recursive<T: LineFormatter>(&mut self, f: &T) {
if let BufferNodeData::Branch(ref mut left, ref mut right) = self.data {
left.update_stats(f);
right.update_stats(f);
match self.data {
BufferNodeData::Branch(ref mut left, ref mut right) => {
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));
},
BufferNodeData::Leaf(ref line) => {
self.vis_dim = f.dimensions(line);
}
}
self.update_stats(f);
}

View File

@ -184,7 +184,7 @@ impl TermUI {
self.width = w as usize;
self.height = h as usize;
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();
},