Fix insert at end of line
This commit is contained in:
parent
a4e8d10c4f
commit
1503589355
1 changed files with 16 additions and 1 deletions
|
|
@ -118,7 +118,7 @@ impl<'a> TextBuffer<'a> {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
font_matches,
|
font_matches,
|
||||||
text_lines: Vec::new(),
|
text_lines: vec![String::new()], // Must have one line
|
||||||
shape_lines: Vec::new(),
|
shape_lines: Vec::new(),
|
||||||
layout_lines: Vec::new(),
|
layout_lines: Vec::new(),
|
||||||
metrics,
|
metrics,
|
||||||
|
|
@ -415,6 +415,21 @@ impl<'a> TextBuffer<'a> {
|
||||||
text_line.insert(insert_i, character);
|
text_line.insert(insert_i, character);
|
||||||
self.cursor.glyph += 1;
|
self.cursor.glyph += 1;
|
||||||
self.reshape_line(line.line_i);
|
self.reshape_line(line.line_i);
|
||||||
|
|
||||||
|
if self.cursor.glyph > self.layout_lines[self.cursor.line].glyphs.len() {
|
||||||
|
if self.cursor.line + 1 < self.layout_lines.len() {
|
||||||
|
self.cursor.glyph -= self.layout_lines[self.cursor.line].glyphs.len();
|
||||||
|
self.cursor.line += 1;
|
||||||
|
|
||||||
|
let lines = self.lines();
|
||||||
|
if (self.cursor.line as i32) < self.scroll
|
||||||
|
|| (self.cursor.line as i32) >= self.scroll + lines
|
||||||
|
{
|
||||||
|
self.scroll = self.cursor.line as i32 - (lines - 1);
|
||||||
|
self.shape_until_scroll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
TextAction::Enter => {
|
TextAction::Enter => {
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue