Maintain keymap editor position when deleting or modifying a binding (#34440)
When a key binding is deleted we keep the exact same scroll bar position. When a keybinding is modified we select that keybinding in it's new position and scroll to it. I also changed save/modified keybinding to use fs.write istead of fs.atomic_write. Atomic write was creating two FS events that some scrollbar bugs when refreshing the keymap editor. Co-authored-by: Ben \<ben@zed.dev\> Release Notes: - N/A
This commit is contained in:
parent
b3747d9a21
commit
f9561da673
2 changed files with 137 additions and 25 deletions
|
@ -3,8 +3,8 @@ use std::{ops::Range, rc::Rc, time::Duration};
|
|||
use editor::{EditorSettings, ShowScrollbar, scroll::ScrollbarAutoHide};
|
||||
use gpui::{
|
||||
AppContext, Axis, Context, Entity, FocusHandle, Length, ListHorizontalSizingBehavior,
|
||||
ListSizingBehavior, MouseButton, Task, UniformListScrollHandle, WeakEntity, transparent_black,
|
||||
uniform_list,
|
||||
ListSizingBehavior, MouseButton, Point, Task, UniformListScrollHandle, WeakEntity,
|
||||
transparent_black, uniform_list,
|
||||
};
|
||||
use settings::Settings as _;
|
||||
use ui::{
|
||||
|
@ -90,6 +90,28 @@ impl TableInteractionState {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_scrollbar_offset(&self, axis: Axis) -> Point<Pixels> {
|
||||
match axis {
|
||||
Axis::Vertical => self.vertical_scrollbar.state.scroll_handle().offset(),
|
||||
Axis::Horizontal => self.horizontal_scrollbar.state.scroll_handle().offset(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_scrollbar_offset(&self, axis: Axis, offset: Point<Pixels>) {
|
||||
match axis {
|
||||
Axis::Vertical => self
|
||||
.vertical_scrollbar
|
||||
.state
|
||||
.scroll_handle()
|
||||
.set_offset(offset),
|
||||
Axis::Horizontal => self
|
||||
.horizontal_scrollbar
|
||||
.state
|
||||
.scroll_handle()
|
||||
.set_offset(offset),
|
||||
}
|
||||
}
|
||||
|
||||
fn update_scrollbar_visibility(&mut self, cx: &mut Context<Self>) {
|
||||
let show_setting = EditorSettings::get_global(cx).scrollbar.show;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue