T59: a prompt with no cell before the cursor, as fish's empty left prompt beside a marked right one, starts the input at its first row, where the press assumed a cell and panicked
This commit is contained in:
3 files changed
+16
-5
No files matched your search
+4
-4
@@ -101,7 +101,7 @@ pub fn press<T>(term: &Term<T>, click: Point, relative: bool) -> Option<Vec<u8>>
|
||||
let cursor = grid.cursor.point;
|
||||
let first = start(term, cursor.line.0)?;
|
||||
let cell = |line: i32, column: usize| &grid[Line(line)][Column(column)];
|
||||
// The prompt ends at its last cell before the cursor.
|
||||
// The prompt ends at its last cell before the cursor; an empty one, at its first row's start.
|
||||
let end = (first..=cursor.line.0)
|
||||
.flat_map(|line| {
|
||||
let width = if line == cursor.line.0 {
|
||||
@@ -112,10 +112,10 @@ pub fn press<T>(term: &Term<T>, click: Point, relative: bool) -> Option<Vec<u8>>
|
||||
(0..width).map(move |column| (line, column))
|
||||
})
|
||||
.filter(|&(line, column)| prompted(cell(line, column)))
|
||||
.last()
|
||||
.expect("a prompt's first row holds its cells");
|
||||
.last();
|
||||
let at = (click.line.0, click.column.0);
|
||||
if at <= end || prompted(cell(at.0, at.1)) {
|
||||
let before = end.map_or(at.0 < first, |end| at <= end);
|
||||
if before || prompted(cell(at.0, at.1)) {
|
||||
return None;
|
||||
}
|
||||
let row = if relative {
|
||||
|
||||
@@ -139,6 +139,17 @@ fn a_shell_that_takes_clicks_hears_the_press_where_it_landed() {
|
||||
sent(&right, click(0, 3), false).as_deref(),
|
||||
Some("\x1b[<0;4;1M")
|
||||
);
|
||||
let empty = term(
|
||||
20,
|
||||
"\x1b7\x1b[1;17H\x1b]133;A;click_events=1\x07~/a\x1b]133;B\x07\x1b8ls",
|
||||
);
|
||||
let left = sent(&empty, click(0, 1), false);
|
||||
assert_eq!(left.as_deref(), Some("\x1b[<0;2;1M"), "only a right prompt");
|
||||
assert_eq!(
|
||||
sent(&empty, click(0, 17), false),
|
||||
None,
|
||||
"on that right prompt"
|
||||
);
|
||||
let two = term(
|
||||
20,
|
||||
"\x1b]133;A;click_events=2\x07~/src\r\n> \x1b]133;B\x07ls",
|
||||
|
||||
Reference in new issue
Block a user