Dont copy prompt start bits to multiple lines when resizing the screen

This makes it unnecessary to modify the prompt marking protocol to
distinguish consecutive prompts without output in between
This commit is contained in:
Kovid Goyal 2021-11-07 18:00:06 +05:30
parent f48a430493
commit c43637f6cc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 2 additions and 11 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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 = []