Skip to content

Commit 2c9795b

Browse files
committed
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.
1 parent cc92fd4 commit 2c9795b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/screen.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,11 @@ impl Screen {
11291129
y: prompt_last_line + 1,
11301130
});
11311131
}
1132+
} else if self.actual_left_prompt.is_none() {
1133+
// If we refreshed and prompt is not visible, print prompt marker
1134+
self.r#move(0, 0);
1135+
self.write_command(Osc133PromptStart);
1136+
self.actual_left_prompt = Some(left_prompt.to_owned());
11321137
}
11331138

11341139
fn o_line(zelf: &Screen, i: usize) -> &Line {
@@ -1182,6 +1187,10 @@ impl Screen {
11821187
} else {
11831188
ClearToEndOfLine
11841189
});
1190+
if i == 0 && start_pos == 0 {
1191+
// Restore prompt marker if we deleted it
1192+
self.write_command(Osc133PromptStart);
1193+
}
11851194
has_cleared_screen = should_clear_screen_this_line;
11861195
has_cleared_line = true;
11871196
}
@@ -1237,6 +1246,10 @@ impl Screen {
12371246
set_color(self, HighlightSpec::new());
12381247
self.r#move(current_width, i);
12391248
self.write_command(ClearToEndOfScreen);
1249+
if i == 0 && current_width == 0 {
1250+
// Restore prompt marker if we deleted it
1251+
self.write_command(Osc133PromptStart);
1252+
}
12401253
has_cleared_screen = true;
12411254
}
12421255
if done {

0 commit comments

Comments
 (0)