Fix NextWord action in Editor when line ends with word boundaries
This commit is contained in:
parent
797f1c7941
commit
4aacd436c3
1 changed files with 8 additions and 8 deletions
|
|
@ -613,14 +613,14 @@ impl Edit for Editor {
|
||||||
Action::NextWord => {
|
Action::NextWord => {
|
||||||
let line: &mut BufferLine = &mut self.buffer.lines[self.cursor.line];
|
let line: &mut BufferLine = &mut self.buffer.lines[self.cursor.line];
|
||||||
if self.cursor.index < line.text().len() {
|
if self.cursor.index < line.text().len() {
|
||||||
for (i, word) in line.text().unicode_word_indices() {
|
self.cursor.index = line
|
||||||
let i = i + word.len();
|
.text()
|
||||||
if i > self.cursor.index {
|
.unicode_word_indices()
|
||||||
self.cursor.index = i;
|
.map(|(i, word)| i + word.len())
|
||||||
self.buffer.set_redraw(true);
|
.find(|&i| i > self.cursor.index)
|
||||||
break;
|
.unwrap_or(line.text().len());
|
||||||
}
|
|
||||||
}
|
self.buffer.set_redraw(true);
|
||||||
} else if self.cursor.line + 1 < self.buffer.lines.len() {
|
} else if self.cursor.line + 1 < self.buffer.lines.len() {
|
||||||
self.cursor.line += 1;
|
self.cursor.line += 1;
|
||||||
self.cursor.index = 0;
|
self.cursor.index = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue