--- rxvt-unicode/src/screen.C 2008/11/04 14:25:10 1.313 +++ rxvt-unicode/src/screen.C 2008/11/04 14:34:13 1.314 @@ -1448,9 +1448,6 @@ void rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW { - int col, row; - rend_t tr; - want_refresh = 1; ZERO_SCROLLBACK (); @@ -1462,7 +1459,7 @@ selection_check (1); min_it (count, ncol - screen.cur.col); - row = screen.cur.row; + int row = screen.cur.row; line_t *line = &ROW(row); @@ -1472,14 +1469,14 @@ switch (insdel) { case INSERT: - for (col = ncol - 1; (col - count) >= screen.cur.col; col--) + line->l = min (line->l + count, ncol); + + for (int col = ncol - 1; (col - count) >= screen.cur.col; col--) { line->t[col] = line->t[col - count]; line->r[col] = line->r[col - count]; } - line->l = min (line->l + count, ncol); - if (selection.op && current_screen == selection.screen && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) { @@ -1507,31 +1504,38 @@ break; case DELETE: - tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); + { + line->l = max (line->l - count, 0); - for (col = screen.cur.col; (col + count) < ncol; col++) - { - line->t[col] = line->t[col + count]; - line->r[col] = line->r[col + count]; - } + rend_t tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); - line->l = max (line->l - count, 0); - scr_blank_line (*line, ncol - count, count, tr); - - if (selection.op && current_screen == selection.screen - && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) - { - if (selection.end.row != screen.cur.row - || (screen.cur.col >= selection.beg.col - count) - || selection.end.col >= ncol) - CLEAR_SELECTION (); - else - { - /* shift selection */ - selection.beg.col -= count; - selection.mark.col -= count; /* XXX: yes? */ - selection.end.col -= count; - } + for (int col = screen.cur.col; (col + count) < ncol; col++) + { + line->t[col] = line->t[col + count]; + line->r[col] = line->r[col + count]; + } + + // nuke wide char at the end + if (line->t[screen.cur.col] == NOCHAR) + scr_kill_char (*line, screen.cur.col); + + scr_blank_line (*line, ncol - count, count, tr); + + if (selection.op && current_screen == selection.screen + && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) + { + if (selection.end.row != screen.cur.row + || (screen.cur.col >= selection.beg.col - count) + || selection.end.col >= ncol) + CLEAR_SELECTION (); + else + { + /* shift selection */ + selection.beg.col -= count; + selection.mark.col -= count; /* XXX: yes? */ + selection.end.col -= count; + } + } } break;