Skip to content

Commit 6e17d83

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 397751b commit 6e17d83

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
@@ -1140,6 +1140,11 @@ impl Screen {
11401140
y: prompt_last_line + 1,
11411141
});
11421142
}
1143+
} else if self.actual_left_prompt.is_none() {
1144+
// If we refreshed and prompt is not visible, print prompt marker
1145+
self.r#move(0, 0);
1146+
self.write_command(Osc133PromptStart);
1147+
self.actual_left_prompt = Some(left_prompt.to_owned());
11431148
}
11441149

11451150
fn o_line(zelf: &Screen, i: usize) -> &Line {
@@ -1193,6 +1198,10 @@ impl Screen {
11931198
} else {
11941199
ClearToEndOfLine
11951200
});
1201+
if i == 0 && start_pos == 0 {
1202+
// Restore prompt marker if we deleted it
1203+
self.write_command(Osc133PromptStart);
1204+
}
11961205
has_cleared_screen = should_clear_screen_this_line;
11971206
has_cleared_line = true;
11981207
}
@@ -1248,6 +1257,10 @@ impl Screen {
12481257
set_color(self, HighlightSpec::new());
12491258
self.r#move(current_width, i);
12501259
self.write_command(ClearToEndOfScreen);
1260+
if i == 0 && current_width == 0 {
1261+
// Restore prompt marker if we deleted it
1262+
self.write_command(Osc133PromptStart);
1263+
}
12511264
has_cleared_screen = true;
12521265
}
12531266
if done {

0 commit comments

Comments
 (0)