Fix handling of tab character when cursor is at end of line and wrapping is enabled

Fixes #7250
This commit is contained in:
Kovid Goyal
2024-03-23 08:43:06 +05:30
parent af82938427
commit a0aba4da4a
3 changed files with 17 additions and 1 deletions

View File

@@ -62,6 +62,8 @@ Detailed list of changes
- macOS: Fix a regression in the previous release that broke rendering of some symbols on some systems (:iss:`7249`) - macOS: Fix a regression in the previous release that broke rendering of some symbols on some systems (:iss:`7249`)
- Fix handling of tab character when cursor is at end of line and wrapping is enabled (:iss:`7250`)
0.33.1 [2024-03-21] 0.33.1 [2024-03-21]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -730,7 +730,18 @@ draw_text_loop(Screen *self, const uint32_t *chars, size_t num_chars, text_loop_
case BS: case BS:
screen_backspace(self); break; screen_backspace(self); break;
case HT: case HT:
screen_tab(self); break; if (UNLIKELY(self->cursor->x >= self->columns)) {
if (self->modes.mDECAWM) {
// xterm discards the TAB in this case so match its behavior
continue_to_next_line(self);
init_text_loop_line(self, s);
} else if (self->columns > 0){
self->cursor->x = self->columns - 1;
if (cursor_on_wide_char_trailer(self, s)) move_cursor_off_wide_char_trailer(self, s);
screen_tab(self);
}
} else screen_tab(self);
break;
case SI: case SI:
screen_change_charset(self, 0); break; screen_change_charset(self, 0); break;
case SO: case SO:

View File

@@ -419,6 +419,9 @@ class TestScreen(BaseTest):
s.draw('*') s.draw('*')
s.cursor_position(2, 2) s.cursor_position(2, 2)
self.ae(str(s.line(0)), '\t*'*13) self.ae(str(s.line(0)), '\t*'*13)
s = self.create_screen(cols=4, lines=2)
s.draw('aaaX\tbbbb')
self.ae(str(s.line(0)) + str(s.line(1)), 'aaaXbbbb')
def test_margins(self): def test_margins(self):
# Taken from vttest/main.c # Taken from vttest/main.c