repl: Scroll down after running code (#14759)
Go to the next line after running code. Allows for fluid coding and running. https://github.com/user-attachments/assets/d11ac05d-7801-4191-b275-3b20302e54c5 Release Notes: - N/A
This commit is contained in:
parent
862f5a0561
commit
cb217381ce
2 changed files with 11 additions and 1 deletions
|
@ -27,7 +27,7 @@ impl Autoscroll {
|
||||||
Self::Strategy(AutoscrollStrategy::Center)
|
Self::Strategy(AutoscrollStrategy::Center)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// scrolls so the neweset cursor is near the top
|
/// scrolls so the newest cursor is near the top
|
||||||
/// (offset by vertical_scroll_margin)
|
/// (offset by vertical_scroll_margin)
|
||||||
pub fn focused() -> Self {
|
pub fn focused() -> Self {
|
||||||
Self::Strategy(AutoscrollStrategy::Focused)
|
Self::Strategy(AutoscrollStrategy::Focused)
|
||||||
|
|
|
@ -7,6 +7,7 @@ use editor::{
|
||||||
display_map::{
|
display_map::{
|
||||||
BlockContext, BlockDisposition, BlockId, BlockProperties, BlockStyle, RenderBlock,
|
BlockContext, BlockDisposition, BlockId, BlockProperties, BlockStyle, RenderBlock,
|
||||||
},
|
},
|
||||||
|
scroll::Autoscroll,
|
||||||
Anchor, AnchorRangeExt as _, Editor, MultiBuffer, ToPoint,
|
Anchor, AnchorRangeExt as _, Editor, MultiBuffer, ToPoint,
|
||||||
};
|
};
|
||||||
use futures::{FutureExt as _, StreamExt as _};
|
use futures::{FutureExt as _, StreamExt as _};
|
||||||
|
@ -329,6 +330,8 @@ impl Session {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let new_cursor_pos = editor_block.invalidation_anchor;
|
||||||
|
|
||||||
self.blocks
|
self.blocks
|
||||||
.insert(message.header.msg_id.clone(), editor_block);
|
.insert(message.header.msg_id.clone(), editor_block);
|
||||||
|
|
||||||
|
@ -352,6 +355,13 @@ impl Session {
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now move the cursor to after the block
|
||||||
|
editor.update(cx, move |editor, cx| {
|
||||||
|
editor.change_selections(Some(Autoscroll::top_relative(8)), cx, |selections| {
|
||||||
|
selections.select_ranges([new_cursor_pos..new_cursor_pos]);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn route(&mut self, message: &JupyterMessage, cx: &mut ViewContext<Self>) {
|
fn route(&mut self, message: &JupyterMessage, cx: &mut ViewContext<Self>) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue