mirror of https://github.com/lapce/lapce.git
This is the minimum number of visible lines above and below the cursor. The default is 1 as per the editors current behavior.
This commit is contained in:
parent
0dd4ea3da5
commit
611b189281
|
@ -46,6 +46,7 @@
|
|||
- [#1441](https://github.com/lapce/lapce/pull/1441): Button for Case-Sensitive search
|
||||
- [#1471](https://github.com/lapce/lapce/pull/1471): Add command to (un)install Lapce from/to PATH
|
||||
- [#1419](https://github.com/lapce/lapce/pull/1419): Add atomic soft tabs: now you can move your cursor over four spaces as if it was a single block
|
||||
- [#1475](https://github.com/lapce/lapce/pull/1475): Add editor setting: "Cursor Surrounding Lines" which sets minimum number of lines above and below cursor
|
||||
|
||||
### Syntax / Extensions
|
||||
- [#957](https://github.com/lapce/lapce/pull/957): Replace existing tree-sitter syntax highlighting code with part of Helix's better implementation
|
||||
|
|
|
@ -13,6 +13,7 @@ tab-width = 4
|
|||
show-tab = true
|
||||
show-bread-crumbs = true
|
||||
scroll-beyond-last-line = true
|
||||
cursor-surrounding-lines = 1
|
||||
sticky-header = true
|
||||
completion-show-documentation = true
|
||||
auto-closing-matching-pairs = true
|
||||
|
|
|
@ -174,6 +174,10 @@ pub struct EditorConfig {
|
|||
pub show_bread_crumbs: bool,
|
||||
#[field_names(desc = "If the editor can scroll beyond the last line")]
|
||||
pub scroll_beyond_last_line: bool,
|
||||
#[field_names(
|
||||
desc = "Set the minimum number of visible lines above and below the cursor"
|
||||
)]
|
||||
pub cursor_surrounding_lines: usize,
|
||||
#[field_names(
|
||||
desc = "Show code context like functions and classes at the top of editor when scroll"
|
||||
)]
|
||||
|
|
|
@ -526,10 +526,14 @@ fn cursor_region(data: &LapceEditorBufferData, text: &mut PietText) -> Rect {
|
|||
line as f64 * line_height
|
||||
};
|
||||
|
||||
let surrounding_lines_height =
|
||||
(data.config.editor.cursor_surrounding_lines as f64 * line_height)
|
||||
.min(data.editor.size.borrow().height / 2.);
|
||||
|
||||
Rect::ZERO
|
||||
.with_size(Size::new(width, line_height))
|
||||
.with_origin(Point::new(cursor_x, y))
|
||||
.inflate(width, line_height)
|
||||
.inflate(width, surrounding_lines_height)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue