diff --git a/kitty/rewrap.h b/kitty/rewrap.h index e07ed98f4..3c02adc93 100644 --- a/kitty/rewrap.h +++ b/kitty/rewrap.h @@ -15,7 +15,7 @@ #define init_src_line(src_y) linebuf_init_line(src, src_y); #endif -#define set_dest_line_attrs(dest_y, continued_) dest->line_attrs[dest_y] = src->line->attrs; if (continued_) dest->line_attrs[dest_y].continued = true; +#define set_dest_line_attrs(dest_y, continued_) dest->line_attrs[dest_y] = src->line->attrs; if (continued_) dest->line_attrs[dest_y].continued = true; src->line->attrs.prompt_kind = UNKNOWN_PROMPT_KIND; #ifndef first_dest_line #define first_dest_line linebuf_init_line(dest, 0); set_dest_line_attrs(0, false) diff --git a/kitty/screen.c b/kitty/screen.c index ee363f594..a5639fbd2 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1973,24 +1973,15 @@ screen_history_scroll_to_prompt(Screen *self, int num_of_prompts_to_jump) { num_of_prompts_to_jump = num_of_prompts_to_jump < 0 ? -num_of_prompts_to_jump : num_of_prompts_to_jump; int y = -self->scrolled_by; #define ensure_y_ok if (y >= (int)self->lines || -y > (int)self->historybuf->count) return false; -#define move_y_to_start_of_prompt while (-y + 1 <= (int)self->historybuf->count && range_line_(self, y - 1)->attrs.prompt_kind == PROMPT_START) y--; -#define move_y_to_end_of_prompt while (y + 1 < (int)self->lines && range_line_(self, y + 1)->attrs.prompt_kind == PROMPT_START) y++; ensure_y_ok; - if (range_line_(self, y)->attrs.prompt_kind == PROMPT_START) { - if (delta < 0) { move_y_to_start_of_prompt; } else { move_y_to_end_of_prompt; } - } while (num_of_prompts_to_jump) { y += delta; ensure_y_ok; if (range_line_(self, y)->attrs.prompt_kind == PROMPT_START) { num_of_prompts_to_jump--; - if (delta < 0) { move_y_to_start_of_prompt; } else { move_y_to_end_of_prompt; } } } - move_y_to_start_of_prompt; #undef ensure_y_ok -#undef move_y_to_start_of_prompt -#undef move_y_to_end_of_prompt unsigned int old = self->scrolled_by; self->scrolled_by = y >= 0 ? 0 : -y; if (old != self->scrolled_by) self->scroll_changed = true; diff --git a/kitty_tests/screen.py b/kitty_tests/screen.py index ceea33227..1ab8d54e5 100644 --- a/kitty_tests/screen.py +++ b/kitty_tests/screen.py @@ -955,7 +955,7 @@ class TestScreen(BaseTest): s.carriage_return(), s.index() s.draw(str(i)) self.assertTrue(s.scroll_to_prompt()) - self.ae(str(s.visual_line(0)), '$ 0') + self.ae(str(s.visual_line(0)), '$ 1') def lco(): a = []