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:
parent
7903f4ea58
commit
3e3a5f04a2
3 changed files with 46 additions and 46 deletions
|
@ -385,30 +385,22 @@ impl LineLayoutCache {
|
||||||
let mut previous_frame = &mut *self.previous_frame.lock();
|
let mut previous_frame = &mut *self.previous_frame.lock();
|
||||||
let mut current_frame = &mut *self.current_frame.write();
|
let mut current_frame = &mut *self.current_frame.write();
|
||||||
|
|
||||||
if let Some(cached_keys) = previous_frame
|
for key in &previous_frame.used_lines[range.start.lines_index..range.end.lines_index] {
|
||||||
.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) {
|
if let Some((key, line)) = previous_frame.lines.remove_entry(key) {
|
||||||
current_frame.lines.insert(key, line);
|
current_frame.lines.insert(key, line);
|
||||||
}
|
}
|
||||||
current_frame.used_lines.push(key.clone());
|
current_frame.used_lines.push(key.clone());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(cached_keys) = previous_frame
|
for key in &previous_frame.used_wrapped_lines
|
||||||
.used_wrapped_lines
|
[range.start.wrapped_lines_index..range.end.wrapped_lines_index]
|
||||||
.get(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) {
|
if let Some((key, line)) = previous_frame.wrapped_lines.remove_entry(key) {
|
||||||
current_frame.wrapped_lines.insert(key, line);
|
current_frame.wrapped_lines.insert(key, line);
|
||||||
}
|
}
|
||||||
current_frame.used_wrapped_lines.push(key.clone());
|
current_frame.used_wrapped_lines.push(key.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub fn truncate_layouts(&self, index: LineLayoutIndex) {
|
pub fn truncate_layouts(&self, index: LineLayoutIndex) {
|
||||||
let mut current_frame = &mut *self.current_frame.write();
|
let mut current_frame = &mut *self.current_frame.write();
|
||||||
|
|
|
@ -1753,17 +1753,12 @@ impl<'a> WindowContext<'a> {
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.map(|listener| listener.take()),
|
.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(
|
window.next_frame.accessed_element_states.extend(
|
||||||
element_states
|
window.rendered_frame.accessed_element_states[range.start.accessed_element_states_index
|
||||||
|
..range.end.accessed_element_states_index]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(id, type_id)| (GlobalElementId(id.0.clone()), *type_id)),
|
.map(|(id, type_id)| (GlobalElementId(id.0.clone()), *type_id)),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
window
|
window
|
||||||
.text_system
|
.text_system
|
||||||
|
|
|
@ -18,8 +18,8 @@ use gpui::{
|
||||||
AsyncWindowContext, ClickEvent, ClipboardItem, Corner, Div, DragMoveEvent, EntityId,
|
AsyncWindowContext, ClickEvent, ClipboardItem, Corner, Div, DragMoveEvent, EntityId,
|
||||||
EventEmitter, ExternalPaths, FocusHandle, FocusOutEvent, FocusableView, KeyContext, Model,
|
EventEmitter, ExternalPaths, FocusHandle, FocusOutEvent, FocusableView, KeyContext, Model,
|
||||||
MouseButton, MouseDownEvent, NavigationDirection, Pixels, Point, PromptLevel, Render,
|
MouseButton, MouseDownEvent, NavigationDirection, Pixels, Point, PromptLevel, Render,
|
||||||
ScrollHandle, Subscription, Task, View, ViewContext, VisualContext, WeakFocusHandle, WeakView,
|
ScrollHandle, Subscription, Task, View, ViewContext, VisualContext, WeakFocusHandle, WeakModel,
|
||||||
WindowContext,
|
WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use language::DiagnosticSeverity;
|
use language::DiagnosticSeverity;
|
||||||
|
@ -286,7 +286,7 @@ pub struct Pane {
|
||||||
nav_history: NavHistory,
|
nav_history: NavHistory,
|
||||||
toolbar: View<Toolbar>,
|
toolbar: View<Toolbar>,
|
||||||
pub(crate) workspace: WeakView<Workspace>,
|
pub(crate) workspace: WeakView<Workspace>,
|
||||||
project: Model<Project>,
|
project: WeakModel<Project>,
|
||||||
drag_split_direction: Option<SplitDirection>,
|
drag_split_direction: Option<SplitDirection>,
|
||||||
can_drop_predicate: Option<Arc<dyn Fn(&dyn Any, &mut WindowContext) -> bool>>,
|
can_drop_predicate: Option<Arc<dyn Fn(&dyn Any, &mut WindowContext) -> bool>>,
|
||||||
custom_drop_handle:
|
custom_drop_handle:
|
||||||
|
@ -411,7 +411,7 @@ impl Pane {
|
||||||
tab_bar_scroll_handle: ScrollHandle::new(),
|
tab_bar_scroll_handle: ScrollHandle::new(),
|
||||||
drag_split_direction: None,
|
drag_split_direction: None,
|
||||||
workspace,
|
workspace,
|
||||||
project,
|
project: project.downgrade(),
|
||||||
can_drop_predicate,
|
can_drop_predicate,
|
||||||
custom_drop_handle: None,
|
custom_drop_handle: None,
|
||||||
can_split_predicate: None,
|
can_split_predicate: None,
|
||||||
|
@ -622,9 +622,12 @@ impl Pane {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_diagnostics(&mut self, cx: &mut ViewContext<Self>) {
|
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;
|
let show_diagnostics = ItemSettings::get_global(cx).show_diagnostics;
|
||||||
self.diagnostics = if show_diagnostics != ShowDiagnostics::Off {
|
self.diagnostics = if show_diagnostics != ShowDiagnostics::Off {
|
||||||
self.project
|
project
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.diagnostic_summaries(false, cx)
|
.diagnostic_summaries(false, cx)
|
||||||
.filter_map(|(project_path, _, diagnostic_summary)| {
|
.filter_map(|(project_path, _, diagnostic_summary)| {
|
||||||
|
@ -638,9 +641,9 @@ impl Pane {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<HashMap<_, _>>()
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
Default::default()
|
HashMap::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -900,7 +903,10 @@ impl Pane {
|
||||||
|
|
||||||
if item.is_singleton(cx) {
|
if item.is_singleton(cx) {
|
||||||
if let Some(&entry_id) = item.project_entry_ids(cx).first() {
|
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) {
|
if let Some(project_path) = project.path_for_entry(entry_id, cx) {
|
||||||
let abs_path = project.absolute_path(&project_path, cx);
|
let abs_path = project.absolute_path(&project_path, cx);
|
||||||
self.nav_history
|
self.nav_history
|
||||||
|
@ -2377,11 +2383,13 @@ impl Pane {
|
||||||
entry_id: Some(entry_id),
|
entry_id: Some(entry_id),
|
||||||
})),
|
})),
|
||||||
cx.handler_for(&pane, move |pane, cx| {
|
cx.handler_for(&pane, move |pane, cx| {
|
||||||
pane.project.update(cx, |_, cx| {
|
pane.project
|
||||||
|
.update(cx, |_, cx| {
|
||||||
cx.emit(project::Event::RevealInProjectPanel(
|
cx.emit(project::Event::RevealInProjectPanel(
|
||||||
ProjectEntryId::from_proto(entry_id),
|
ProjectEntryId::from_proto(entry_id),
|
||||||
))
|
))
|
||||||
});
|
})
|
||||||
|
.ok();
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.when_some(parent_abs_path, |menu, parent_abs_path| {
|
.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 should_display_tab_bar = self.should_display_tab_bar.clone();
|
||||||
let display_tab_bar = should_display_tab_bar(cx);
|
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()
|
v_flex()
|
||||||
.key_context(key_context)
|
.key_context(key_context)
|
||||||
|
@ -2972,9 +2983,11 @@ impl Render for Pane {
|
||||||
.map(ProjectEntryId::from_proto)
|
.map(ProjectEntryId::from_proto)
|
||||||
.or_else(|| pane.active_item()?.project_entry_ids(cx).first().copied());
|
.or_else(|| pane.active_item()?.project_entry_ids(cx).first().copied());
|
||||||
if let Some(entry_id) = entry_id {
|
if let Some(entry_id) = entry_id {
|
||||||
pane.project.update(cx, |_, cx| {
|
pane.project
|
||||||
|
.update(cx, |_, cx| {
|
||||||
cx.emit(project::Event::RevealInProjectPanel(entry_id))
|
cx.emit(project::Event::RevealInProjectPanel(entry_id))
|
||||||
});
|
})
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
@ -2982,7 +2995,7 @@ impl Render for Pane {
|
||||||
pane.child(self.render_tab_bar(cx))
|
pane.child(self.render_tab_bar(cx))
|
||||||
})
|
})
|
||||||
.child({
|
.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
|
// main content
|
||||||
div()
|
div()
|
||||||
.flex_1()
|
.flex_1()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue