diff --git a/kitty/history.c b/kitty/history.c index fbe9e93ca..829637ed4 100644 --- a/kitty/history.c +++ b/kitty/history.c @@ -638,7 +638,9 @@ historybuf_next_dest_line(HistoryBuf *self, ANSIBuf *as_ansi_buf, Line *src_line history_buf_set_last_char_as_continuation(self, 0, continued); bool needs_clear; index_type idx = historybuf_push(self, as_ansi_buf, &needs_clear); - *attrptr(self, idx) = src_line->attrs; + LineAttrs *a = attrptr(self, idx); + *a = src_line->attrs; + if (continued) a->prompt_kind = UNKNOWN_PROMPT_KIND; init_line(self, idx, dest_line); if (needs_clear) { zero_at_ptr_count(dest_line->cpu_cells, dest_line->xnum); diff --git a/kitty_tests/screen.py b/kitty_tests/screen.py index 4111baa11..a8dbd16f7 100644 --- a/kitty_tests/screen.py +++ b/kitty_tests/screen.py @@ -1258,6 +1258,20 @@ class TestScreen(BaseTest): s.scroll_to_prompt(1) self.ae(lvco(), '0x\n1x') + # test that post rewrap prompt lines have correct attributes + s = self.create_screen(cols=5, lines=5, scrollback=15) + draw_prompt('P' * (s.columns - 2)) + draw_output(s.lines + 1, 'a') # ensure prompt is in scrollback + draw_prompt('Q' * (s.columns - 2)) + self.ae(str(s.visual_line(0)), '3a') + s.scroll_to_prompt() + self.ae(str(s.visual_line(0)), '$ PPP') + s.scroll_to_prompt(1) + self.ae(str(s.visual_line(0)), '3a') + s.resize(s.lines, s.columns - 2) + s.scroll_to_prompt() + self.ae(str(s.visual_line(0)), '$ P') + # last command output without line break s = self.create_screen(cols=10, lines=3) draw_prompt('p1')