fix new editor scroll
@@ -1584,7 +1584,21 @@ fn lifecycle(
find.lifecycle(ctx, event, data, env);
}
- if let LifeCycle::HotChanged(is_hot) = event {
+ match event {
+ LifeCycle::WidgetAdded => {
+ let editor = data.main_split.editors.get(&self.view_id).unwrap();
+ if editor.scroll_offset.x > 0.0 || editor.scroll_offset.y > 0.0 {
+ ctx.submit_command(Command::new(
+ LAPCE_UI_COMMAND,
+ LapceUICommand::ForceScrollTo(
+ editor.scroll_offset.x,
+ editor.scroll_offset.y,
+ ),
+ Target::Widget(editor.view_id),
+ ));
+ }
+ }
+ LifeCycle::HotChanged(is_hot) => {
self.header.widget_mut().view_is_hot = *is_hot;
let editor = data.main_split.editors.get(&self.view_id).unwrap();
if let Some(editor_tab_id) = editor.tab_id.as_ref() {
@@ -1594,6 +1608,8 @@ fn lifecycle(
}
ctx.request_layout();
}
+ _ => (),
+ }
self.header.lifecycle(ctx, event, data, env);
self.editor.lifecycle(ctx, event, data, env);
}
