Try to always maintain prompt marker at (0, 0)

First, print prompt marker on repaint even if prompt is not visible.
Second, if we issue a clear at (0, 0) we need to restore marker.

This is necessary for features like Kitty's prompt navigation (`ctrl-shift-{jk}`),
which requires the prompt marker at the top of the scrolled command line
to actually jump back to the original state.

Closes #11911
This commit is contained in:
kerty
2025-10-15 14:43:34 +03:00
committed by Johannes Altmanninger
parent 5cfcfc64d8
commit 755d5ae222

View File

@@ -1127,6 +1127,11 @@ fn update(&mut self, vars: &dyn Environment, left_prompt: &wstr, right_prompt: &
y: prompt_last_line + 1,
});
}
} else if self.actual_left_prompt.is_none() {
// If we refreshed and prompt is not visible, print prompt marker
self.r#move(0, 0);
self.write_command(Osc133PromptStart);
self.actual_left_prompt = Some(left_prompt.to_owned());
}
fn o_line(zelf: &Screen, i: usize) -> &Line {
@@ -1180,6 +1185,10 @@ fn s_line(zelf: &Screen, i: usize) -> &Line {
} else {
ClearToEndOfLine
});
if i == 0 && start_pos == 0 {
// Restore prompt marker if we deleted it
self.write_command(Osc133PromptStart);
}
has_cleared_screen = should_clear_screen_this_line;
has_cleared_line = true;
}
@@ -1235,6 +1244,10 @@ fn s_line(zelf: &Screen, i: usize) -> &Line {
set_color(self, HighlightSpec::new());
self.r#move(current_width, i);
self.write_command(ClearToEndOfScreen);
if i == 0 && current_width == 0 {
// Restore prompt marker if we deleted it
self.write_command(Osc133PromptStart);
}
has_cleared_screen = true;
}
if done {