editor: Add scroll_beyond_last_line setting (#11155)
Add `scroll_beyond_last_line` setting with 3 options: - `one_page`: The default (current) behaviour of scrolling one more page beyond the last line. <img width="568" alt="SCR-20240429-sxry" src="https://github.com/zed-industries/zed/assets/126383/1effbee9-759f-4858-9022-83bbb208ef82"> - `off`: No scrolling beyond the last line. <img width="568" alt="SCR-20240429-syhv" src="https://github.com/zed-industries/zed/assets/126383/5391b1d7-918d-43f3-8a6f-7642ef32d174"> - `vertical_scroll_margin`: Scroll beyond the last line by the same number of lines as `vertical_scroll_margin`. Matches the behaviour of keyboard scrolling. <img width="568" alt="SCR-20240429-sypc" src="https://github.com/zed-industries/zed/assets/126383/bb9cc928-e515-4503-88f7-e434c45d742f"> Release Notes: - Added `scroll_beyond_last_line` setting ([#4962](https://github.com/zed-industries/zed/issues/4962)).
This commit is contained in:
@@ -15,6 +15,7 @@ pub struct EditorSettings {
|
||||
pub toolbar: Toolbar,
|
||||
pub scrollbar: Scrollbar,
|
||||
pub gutter: Gutter,
|
||||
pub scroll_beyond_last_line: ScrollBeyondLastLine,
|
||||
pub vertical_scroll_margin: f32,
|
||||
pub scroll_sensitivity: f32,
|
||||
pub relative_line_numbers: bool,
|
||||
@@ -116,6 +117,22 @@ pub enum MultiCursorModifier {
|
||||
CmdOrCtrl,
|
||||
}
|
||||
|
||||
/// Whether the editor will scroll beyond the last line.
|
||||
///
|
||||
/// Default: one_page
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ScrollBeyondLastLine {
|
||||
/// The editor will not scroll beyond the last line.
|
||||
Off,
|
||||
|
||||
/// The editor will scroll beyond the last line by one page.
|
||||
OnePage,
|
||||
|
||||
/// The editor will scroll beyond the last line by the same number of lines as vertical_scroll_margin.
|
||||
VerticalScrollMargin,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct EditorSettingsContent {
|
||||
/// Whether the cursor blinks in the editor.
|
||||
@@ -158,6 +175,10 @@ pub struct EditorSettingsContent {
|
||||
pub scrollbar: Option<ScrollbarContent>,
|
||||
/// Gutter related settings
|
||||
pub gutter: Option<GutterContent>,
|
||||
/// Whether the editor will scroll beyond the last line.
|
||||
///
|
||||
/// Default: one_page
|
||||
pub scroll_beyond_last_line: Option<ScrollBeyondLastLine>,
|
||||
/// The number of lines to keep above/below the cursor when auto-scrolling.
|
||||
///
|
||||
/// Default: 3.
|
||||
|
||||
Reference in New Issue
Block a user