Fix window double borrows (#23739)
Fix bugs caused by the window context PR, where the window could be on the stack and is then requested from the App. This PR also adds derive macros for `AppContext` and `VisualContext` so that it's easy to define further contexts in API code, such as `editor::BlockContext`. Release Notes: - N/A
This commit is contained in:
parent
29bfb56739
commit
a7c549b85b
24 changed files with 465 additions and 297 deletions
|
@ -5,8 +5,8 @@ use editor::{
|
|||
actions::Tab, scroll::Autoscroll, Anchor, Editor, MultiBufferSnapshot, ToOffset, ToPoint,
|
||||
};
|
||||
use gpui::{
|
||||
div, prelude::*, AnyWindowHandle, App, DismissEvent, Entity, EventEmitter, FocusHandle,
|
||||
Focusable, Render, SharedString, Styled, Subscription,
|
||||
div, prelude::*, App, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, Render,
|
||||
SharedString, Styled, Subscription,
|
||||
};
|
||||
use language::Buffer;
|
||||
use settings::Settings;
|
||||
|
@ -133,19 +133,15 @@ impl GoToLine {
|
|||
}
|
||||
}
|
||||
|
||||
fn release(&mut self, window: AnyWindowHandle, cx: &mut App) {
|
||||
window
|
||||
.update(cx, |_, window, cx| {
|
||||
let scroll_position = self.prev_scroll_position.take();
|
||||
self.active_editor.update(cx, |editor, cx| {
|
||||
editor.clear_row_highlights::<GoToLineRowHighlights>();
|
||||
if let Some(scroll_position) = scroll_position {
|
||||
editor.set_scroll_position(scroll_position, window, cx);
|
||||
}
|
||||
cx.notify();
|
||||
})
|
||||
})
|
||||
.ok();
|
||||
fn release(&mut self, window: &mut Window, cx: &mut App) {
|
||||
let scroll_position = self.prev_scroll_position.take();
|
||||
self.active_editor.update(cx, |editor, cx| {
|
||||
editor.clear_row_highlights::<GoToLineRowHighlights>();
|
||||
if let Some(scroll_position) = scroll_position {
|
||||
editor.set_scroll_position(scroll_position, window, cx);
|
||||
}
|
||||
cx.notify();
|
||||
})
|
||||
}
|
||||
|
||||
fn on_line_editor_event(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue