Skip to content

Commit 94b7858

Browse files
committed
fixup! Fix moving cursor when highlight_char() is false
1 parent 3925456 commit 94b7858

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/edit.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,17 @@ impl<'out, 'prompt, H: Helper> State<'out, 'prompt, H> {
129129

130130
pub fn move_cursor(&mut self) -> Result<()> {
131131
// calculate the desired position of the cursor
132-
let cursor = self
133-
.out
134-
.calculate_position(&self.line[..self.line.pos()], Position::default(), 0);
135-
if self.layout.cursor == cursor {
132+
let new_layout = self.out.compute_layout(
133+
&self.prompt, &self.line, None);
134+
if new_layout.cursor == self.layout.cursor {
136135
return Ok(());
137136
}
138137
if self.highlight_char() {
139138
self.refresh_default(Info::NoHint)?;
140139
} else {
141-
self.out.move_cursor(self.layout.cursor, cursor)?;
140+
self.out.move_cursor(self.layout.cursor, new_layout.cursor)?;
142141
self.layout.prompt_size = self.prompt.size;
143-
self.layout.cursor = cursor;
142+
self.layout.cursor = new_layout.cursor;
144143
debug_assert!(self.layout.cursor <= self.layout.end);
145144
}
146145
Ok(())

0 commit comments

Comments
 (0)