Misc bug fixes on the way towards a proper editing interface.
This commit is contained in:
parent
a56ff95221
commit
f469240860
|
@ -150,9 +150,7 @@ impl TextNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
if child_rot {
|
if child_rot {
|
||||||
if let TextNodeData::Branch(_, ref mut rc) = right.data {
|
left.rotate_left();
|
||||||
rc.rotate_left();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rot = 1;
|
rot = 1;
|
||||||
|
@ -167,9 +165,7 @@ impl TextNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
if child_rot {
|
if child_rot {
|
||||||
if let TextNodeData::Branch(ref mut lc, _) = right.data {
|
right.rotate_right();
|
||||||
lc.rotate_right();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rot = -1;
|
rot = -1;
|
||||||
|
@ -342,6 +338,11 @@ impl TextNode {
|
||||||
let mut col = offset;
|
let mut col = offset;
|
||||||
|
|
||||||
for c in iter {
|
for c in iter {
|
||||||
|
// Check if we've hit a relevant character
|
||||||
|
if line > pos.0 || (line == pos.0 && col >= pos.1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Increment counters
|
// Increment counters
|
||||||
if c == '\n' {
|
if c == '\n' {
|
||||||
line += 1;
|
line += 1;
|
||||||
|
@ -351,11 +352,6 @@ impl TextNode {
|
||||||
col += 1;
|
col += 1;
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
|
|
||||||
// Check if we've hit a relevant character
|
|
||||||
if line > pos.0 || (line == pos.0 && col > pos.1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've reached the end of this text block but
|
// If we've reached the end of this text block but
|
||||||
|
|
|
@ -62,6 +62,14 @@ impl Editor {
|
||||||
self.buffer.insert_text(text, pos);
|
self.buffer.insert_text(text, pos);
|
||||||
|
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
|
|
||||||
|
if text == "\n" {
|
||||||
|
self.cursor.0 += 1;
|
||||||
|
self.cursor.1 = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.cursor.1 += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cursor_left(&mut self) {
|
pub fn cursor_left(&mut self) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user