1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-24 07:46:59 +03:00

run down an off-by-one in VPA handling

This manifested with vim-inside-tmux losing my top tmux status line.

Add a test!
This commit is contained in:
Wez Furlong 2018-02-11 23:56:42 -08:00
parent 0870e6c7e4
commit ad3524bfc8
5 changed files with 32 additions and 5 deletions

View File

@ -486,7 +486,7 @@ impl<'a> Iterator for CSIParser<'a> {
// VPA: Line Position Absolute
('d', &[], Some(&[])) => Some(CSIAction::LinePosition(Position::Absolute(0))),
('d', &[], Some(&[n])) => Some(CSIAction::LinePosition(Position::Absolute(n))),
('d', &[], Some(&[n])) => Some(CSIAction::LinePosition(Position::Absolute(n - 1))),
// VPR: Line Position Relative
('e', &[], Some(&[])) => Some(CSIAction::LinePosition(Position::Relative(0))),

View File

@ -97,11 +97,11 @@ impl Screen {
) -> &Cell {
let line_idx = self.phys_row(y);
debug!(
"set_cell x,y {},{}, line_idx = {} {} {:?}",
"set_cell {} x={} y={} phys={} {:?}",
c,
x,
y,
line_idx,
c,
attr
);
@ -177,6 +177,7 @@ impl Screen {
/// If the top of the region is the top of the visible display, rather than
/// removing the lines we let them go into the scrollback.
pub fn scroll_up(&mut self, scroll_region: &Range<VisibleRowIndex>, num_rows: usize) {
debug!("scroll_up {:?} {}", scroll_region, num_rows);
let phys_scroll = self.phys_range(&scroll_region);
assert!(num_rows <= phys_scroll.end - phys_scroll.start);
@ -233,6 +234,7 @@ impl Screen {
/// In other words, we remove (bottom-num_rows..bottom) and then insert num_rows
/// at scroll_top.
pub fn scroll_down(&mut self, scroll_region: &Range<VisibleRowIndex>, num_rows: usize) {
debug!("scroll_down {:?} {}", scroll_region, num_rows);
let phys_scroll = self.phys_range(&scroll_region);
assert!(num_rows <= phys_scroll.end - phys_scroll.start);

View File

@ -1147,10 +1147,12 @@ impl vte::Perform for TerminalState {
(b'\\', &[], &[]) => {}
// Application Keypad (DECKPAM)
(b'=', &[], &[]) => {
debug!("DECKPAM on");
self.application_keypad = true;
}
// Normal Keypad (DECKPAM)
(b'>', &[], &[]) => {
debug!("DECKPAM off");
self.application_keypad = false;
}
// Reverse Index (RI)
@ -1163,9 +1165,13 @@ impl vte::Perform for TerminalState {
(b'H', &[], &[]) => self.c1_hts(),
// Enable alternate character set mode (smacs)
(b'0', &[b'('], &[]) => {}
(b'0', &[b'('], &[]) => {
debug!("ESC: smacs");
}
// Exit alternate character set mode (rmacs)
(b'B', &[b'('], &[]) => {}
(b'B', &[b'('], &[]) => {
debug!("ESC: rmacs");
}
// DECSC - Save Cursor
(b'7', &[], &[]) => self.perform_csi(CSIAction::SaveCursor),

18
term/src/test/csi.rs Normal file
View File

@ -0,0 +1,18 @@
use super::*;
#[test]
fn test_vpa() {
let mut term = TestTerm::new(3, 4, 0);
term.assert_cursor_pos(0, 0, None);
term.print("a\nb\nc");
term.assert_cursor_pos(1, 2, None);
term.print("\x1b[d");
term.assert_cursor_pos(1, 0, None);
term.print("\n\n");
term.assert_cursor_pos(0, 2, None);
// escapes are 1-based, so check that we're handling that
// when we parse them!
term.print("\x1b[2d");
term.assert_cursor_pos(0, 1, None);
}

View File

@ -5,6 +5,7 @@ use super::*;
mod selection;
mod c0;
mod c1;
mod csi;
#[derive(Default, Debug)]
struct TestHost {