prompt: Cap anchor to line length in cursor calculation
This prevents a panic when using `C-w` on a long single-word prompt line for example. Connects #12036
This commit is contained in:
parent
6b044aeb29
commit
9d6ea773e9
1 changed files with 2 additions and 1 deletions
|
@ -734,8 +734,9 @@ impl Component for Prompt {
|
|||
.clip_left(self.prompt.len() as u16)
|
||||
.clip_right(if self.prompt.len() > 0 { 0 } else { 2 });
|
||||
|
||||
let anchor = self.anchor.min(self.line.len().saturating_sub(1));
|
||||
let mut col = area.left() as usize
|
||||
+ UnicodeWidthStr::width(&self.line[self.anchor..self.cursor.max(self.anchor)]);
|
||||
+ UnicodeWidthStr::width(&self.line[anchor..self.cursor.max(anchor)]);
|
||||
|
||||
// ensure the cursor does not go beyond elipses
|
||||
if self.truncate_end && self.cursor - self.anchor >= self.line_area.width as usize {
|
||||
|
|
Loading…
Add table
Reference in a new issue