Small fixes after terminal split (#22468)

* removes cache access workarounds as
https://github.com/zed-industries/zed/pull/21165 is supposed to fix this
* use `WeakModel<Project>` inside `Pane` just in case 

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2024-12-28 19:29:13 +02:00 committed by GitHub
parent 7903f4ea58
commit 3e3a5f04a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 46 additions and 46 deletions

View file

@ -385,28 +385,20 @@ impl LineLayoutCache {
let mut previous_frame = &mut *self.previous_frame.lock();
let mut current_frame = &mut *self.current_frame.write();
if let Some(cached_keys) = previous_frame
.used_lines
.get(range.start.lines_index..range.end.lines_index)
{
for key in cached_keys {
if let Some((key, line)) = previous_frame.lines.remove_entry(key) {
current_frame.lines.insert(key, line);
}
current_frame.used_lines.push(key.clone());
for key in &previous_frame.used_lines[range.start.lines_index..range.end.lines_index] {
if let Some((key, line)) = previous_frame.lines.remove_entry(key) {
current_frame.lines.insert(key, line);
}
current_frame.used_lines.push(key.clone());
}
if let Some(cached_keys) = previous_frame
.used_wrapped_lines
.get(range.start.wrapped_lines_index..range.end.wrapped_lines_index)
for key in &previous_frame.used_wrapped_lines
[range.start.wrapped_lines_index..range.end.wrapped_lines_index]
{
for key in cached_keys {
if let Some((key, line)) = previous_frame.wrapped_lines.remove_entry(key) {
current_frame.wrapped_lines.insert(key, line);
}
current_frame.used_wrapped_lines.push(key.clone());
if let Some((key, line)) = previous_frame.wrapped_lines.remove_entry(key) {
current_frame.wrapped_lines.insert(key, line);
}
current_frame.used_wrapped_lines.push(key.clone());
}
}

View file

@ -1753,17 +1753,12 @@ impl<'a> WindowContext<'a> {
.iter_mut()
.map(|listener| listener.take()),
);
if let Some(element_states) = window
.rendered_frame
.accessed_element_states
.get(range.start.accessed_element_states_index..range.end.accessed_element_states_index)
{
window.next_frame.accessed_element_states.extend(
element_states
.iter()
.map(|(id, type_id)| (GlobalElementId(id.0.clone()), *type_id)),
);
}
window.next_frame.accessed_element_states.extend(
window.rendered_frame.accessed_element_states[range.start.accessed_element_states_index
..range.end.accessed_element_states_index]
.iter()
.map(|(id, type_id)| (GlobalElementId(id.0.clone()), *type_id)),
);
window
.text_system

View file

@ -18,8 +18,8 @@ use gpui::{
AsyncWindowContext, ClickEvent, ClipboardItem, Corner, Div, DragMoveEvent, EntityId,
EventEmitter, ExternalPaths, FocusHandle, FocusOutEvent, FocusableView, KeyContext, Model,
MouseButton, MouseDownEvent, NavigationDirection, Pixels, Point, PromptLevel, Render,
ScrollHandle, Subscription, Task, View, ViewContext, VisualContext, WeakFocusHandle, WeakView,
WindowContext,
ScrollHandle, Subscription, Task, View, ViewContext, VisualContext, WeakFocusHandle, WeakModel,
WeakView, WindowContext,
};
use itertools::Itertools;
use language::DiagnosticSeverity;
@ -286,7 +286,7 @@ pub struct Pane {
nav_history: NavHistory,
toolbar: View<Toolbar>,
pub(crate) workspace: WeakView<Workspace>,
project: Model<Project>,
project: WeakModel<Project>,
drag_split_direction: Option<SplitDirection>,
can_drop_predicate: Option<Arc<dyn Fn(&dyn Any, &mut WindowContext) -> bool>>,
custom_drop_handle:
@ -411,7 +411,7 @@ impl Pane {
tab_bar_scroll_handle: ScrollHandle::new(),
drag_split_direction: None,
workspace,
project,
project: project.downgrade(),
can_drop_predicate,
custom_drop_handle: None,
can_split_predicate: None,
@ -622,9 +622,12 @@ impl Pane {
}
fn update_diagnostics(&mut self, cx: &mut ViewContext<Self>) {
let Some(project) = self.project.upgrade() else {
return;
};
let show_diagnostics = ItemSettings::get_global(cx).show_diagnostics;
self.diagnostics = if show_diagnostics != ShowDiagnostics::Off {
self.project
project
.read(cx)
.diagnostic_summaries(false, cx)
.filter_map(|(project_path, _, diagnostic_summary)| {
@ -638,9 +641,9 @@ impl Pane {
None
}
})
.collect::<HashMap<_, _>>()
.collect()
} else {
Default::default()
HashMap::default()
}
}
@ -900,7 +903,10 @@ impl Pane {
if item.is_singleton(cx) {
if let Some(&entry_id) = item.project_entry_ids(cx).first() {
let project = self.project.read(cx);
let Some(project) = self.project.upgrade() else {
return;
};
let project = project.read(cx);
if let Some(project_path) = project.path_for_entry(entry_id, cx) {
let abs_path = project.absolute_path(&project_path, cx);
self.nav_history
@ -2377,11 +2383,13 @@ impl Pane {
entry_id: Some(entry_id),
})),
cx.handler_for(&pane, move |pane, cx| {
pane.project.update(cx, |_, cx| {
cx.emit(project::Event::RevealInProjectPanel(
ProjectEntryId::from_proto(entry_id),
))
});
pane.project
.update(cx, |_, cx| {
cx.emit(project::Event::RevealInProjectPanel(
ProjectEntryId::from_proto(entry_id),
))
})
.ok();
}),
)
.when_some(parent_abs_path, |menu, parent_abs_path| {
@ -2862,7 +2870,10 @@ impl Render for Pane {
let should_display_tab_bar = self.should_display_tab_bar.clone();
let display_tab_bar = should_display_tab_bar(cx);
let is_local = self.project.read(cx).is_local();
let Some(project) = self.project.upgrade() else {
return div().track_focus(&self.focus_handle(cx));
};
let is_local = project.read(cx).is_local();
v_flex()
.key_context(key_context)
@ -2972,9 +2983,11 @@ impl Render for Pane {
.map(ProjectEntryId::from_proto)
.or_else(|| pane.active_item()?.project_entry_ids(cx).first().copied());
if let Some(entry_id) = entry_id {
pane.project.update(cx, |_, cx| {
cx.emit(project::Event::RevealInProjectPanel(entry_id))
});
pane.project
.update(cx, |_, cx| {
cx.emit(project::Event::RevealInProjectPanel(entry_id))
})
.ok();
}
}),
)
@ -2982,7 +2995,7 @@ impl Render for Pane {
pane.child(self.render_tab_bar(cx))
})
.child({
let has_worktrees = self.project.read(cx).worktrees(cx).next().is_some();
let has_worktrees = project.read(cx).worktrees(cx).next().is_some();
// main content
div()
.flex_1()