Cleanups preparing for WindowContext refactor (#22475)
* Remove unnecessary WindowContext and ViewContext '_ lifetimes * Removed some cases where WindowContext has a different name than `cx`. Release Notes: - N/A
This commit is contained in:
parent
9815358bdd
commit
016b5d60e1
41 changed files with 127 additions and 152 deletions
|
@ -4966,8 +4966,8 @@ fn fold_toggle(
|
||||||
) -> impl Fn(
|
) -> impl Fn(
|
||||||
MultiBufferRow,
|
MultiBufferRow,
|
||||||
bool,
|
bool,
|
||||||
Arc<dyn Fn(bool, &mut WindowContext<'_>) + Send + Sync>,
|
Arc<dyn Fn(bool, &mut WindowContext) + Send + Sync>,
|
||||||
&mut WindowContext<'_>,
|
&mut WindowContext,
|
||||||
) -> AnyElement {
|
) -> AnyElement {
|
||||||
move |row, is_folded, fold, _cx| {
|
move |row, is_folded, fold, _cx| {
|
||||||
Disclosure::new((name, row.0 as u64), !is_folded)
|
Disclosure::new((name, row.0 as u64), !is_folded)
|
||||||
|
|
|
@ -27,8 +27,8 @@ enum SlashCommandEntry {
|
||||||
Info(SlashCommandInfo),
|
Info(SlashCommandInfo),
|
||||||
Advert {
|
Advert {
|
||||||
name: SharedString,
|
name: SharedString,
|
||||||
renderer: fn(&mut WindowContext<'_>) -> AnyElement,
|
renderer: fn(&mut WindowContext) -> AnyElement,
|
||||||
on_confirm: fn(&mut WindowContext<'_>),
|
on_confirm: fn(&mut WindowContext),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ fn is_c_language(language: &Language) -> bool {
|
||||||
pub fn switch_source_header(
|
pub fn switch_source_header(
|
||||||
editor: &mut Editor,
|
editor: &mut Editor,
|
||||||
_: &SwitchSourceHeader,
|
_: &SwitchSourceHeader,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
let Some(project) = &editor.project else {
|
let Some(project) = &editor.project else {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3513,7 +3513,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visible_inlay_hints(&self, cx: &ViewContext<'_, Editor>) -> Vec<Inlay> {
|
fn visible_inlay_hints(&self, cx: &ViewContext<Editor>) -> Vec<Inlay> {
|
||||||
self.display_map
|
self.display_map
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.current_inlays()
|
.current_inlays()
|
||||||
|
@ -6009,7 +6009,7 @@ impl Editor {
|
||||||
fn gather_revert_changes(
|
fn gather_revert_changes(
|
||||||
&mut self,
|
&mut self,
|
||||||
selections: &[Selection<Point>],
|
selections: &[Selection<Point>],
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> HashMap<BufferId, Vec<(Range<text::Anchor>, Rope)>> {
|
) -> HashMap<BufferId, Vec<(Range<text::Anchor>, Rope)>> {
|
||||||
let mut revert_changes = HashMap::default();
|
let mut revert_changes = HashMap::default();
|
||||||
let snapshot = self.snapshot(cx);
|
let snapshot = self.snapshot(cx);
|
||||||
|
@ -8936,7 +8936,7 @@ impl Editor {
|
||||||
fn templates_with_tags(
|
fn templates_with_tags(
|
||||||
project: &Model<Project>,
|
project: &Model<Project>,
|
||||||
runnable: &mut Runnable,
|
runnable: &mut Runnable,
|
||||||
cx: &WindowContext<'_>,
|
cx: &WindowContext,
|
||||||
) -> Vec<(TaskSourceKind, TaskTemplate)> {
|
) -> Vec<(TaskSourceKind, TaskTemplate)> {
|
||||||
let (inventory, worktree_id, file) = project.read_with(cx, |project, cx| {
|
let (inventory, worktree_id, file) = project.read_with(cx, |project, cx| {
|
||||||
let (worktree_id, file) = project
|
let (worktree_id, file) = project
|
||||||
|
@ -9248,7 +9248,7 @@ impl Editor {
|
||||||
&mut self,
|
&mut self,
|
||||||
snapshot: &EditorSnapshot,
|
snapshot: &EditorSnapshot,
|
||||||
position: Point,
|
position: Point,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> Option<MultiBufferDiffHunk> {
|
) -> Option<MultiBufferDiffHunk> {
|
||||||
for (ix, position) in [position, Point::zero()].into_iter().enumerate() {
|
for (ix, position) in [position, Point::zero()].into_iter().enumerate() {
|
||||||
if let Some(hunk) = self.go_to_next_hunk_in_direction(
|
if let Some(hunk) = self.go_to_next_hunk_in_direction(
|
||||||
|
@ -9277,7 +9277,7 @@ impl Editor {
|
||||||
&mut self,
|
&mut self,
|
||||||
snapshot: &EditorSnapshot,
|
snapshot: &EditorSnapshot,
|
||||||
position: Point,
|
position: Point,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> Option<MultiBufferDiffHunk> {
|
) -> Option<MultiBufferDiffHunk> {
|
||||||
for (ix, position) in [position, snapshot.buffer_snapshot.max_point()]
|
for (ix, position) in [position, snapshot.buffer_snapshot.max_point()]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -13842,7 +13842,7 @@ impl SemanticsProvider for Model<Project> {
|
||||||
fn inlay_hint_settings(
|
fn inlay_hint_settings(
|
||||||
location: Anchor,
|
location: Anchor,
|
||||||
snapshot: &MultiBufferSnapshot,
|
snapshot: &MultiBufferSnapshot,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> InlayHintSettings {
|
) -> InlayHintSettings {
|
||||||
let file = snapshot.file_at(location);
|
let file = snapshot.file_at(location);
|
||||||
let language = snapshot.language_at(location).map(|l| l.name());
|
let language = snapshot.language_at(location).map(|l| l.name());
|
||||||
|
|
|
@ -4991,7 +4991,7 @@ fn jump_data(
|
||||||
block_row_start: DisplayRow,
|
block_row_start: DisplayRow,
|
||||||
height: u32,
|
height: u32,
|
||||||
for_excerpt: &ExcerptInfo,
|
for_excerpt: &ExcerptInfo,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) -> JumpData {
|
) -> JumpData {
|
||||||
let range = &for_excerpt.range;
|
let range = &for_excerpt.range;
|
||||||
let buffer = &for_excerpt.buffer;
|
let buffer = &for_excerpt.buffer;
|
||||||
|
@ -5066,7 +5066,7 @@ fn prepaint_gutter_button(
|
||||||
scroll_pixel_position: gpui::Point<Pixels>,
|
scroll_pixel_position: gpui::Point<Pixels>,
|
||||||
gutter_hitbox: &Hitbox,
|
gutter_hitbox: &Hitbox,
|
||||||
rows_with_hunk_bounds: &HashMap<DisplayRow, Bounds<Pixels>>,
|
rows_with_hunk_bounds: &HashMap<DisplayRow, Bounds<Pixels>>,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) -> AnyElement {
|
) -> AnyElement {
|
||||||
let mut button = button.into_any_element();
|
let mut button = button.into_any_element();
|
||||||
let available_space = size(
|
let available_space = size(
|
||||||
|
@ -5099,7 +5099,7 @@ fn render_inline_blame_entry(
|
||||||
blame_entry: BlameEntry,
|
blame_entry: BlameEntry,
|
||||||
style: &EditorStyle,
|
style: &EditorStyle,
|
||||||
workspace: Option<WeakView<Workspace>>,
|
workspace: Option<WeakView<Workspace>>,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) -> AnyElement {
|
) -> AnyElement {
|
||||||
let relative_timestamp = blame_entry_relative_timestamp(&blame_entry);
|
let relative_timestamp = blame_entry_relative_timestamp(&blame_entry);
|
||||||
|
|
||||||
|
@ -5139,7 +5139,7 @@ fn render_blame_entry(
|
||||||
style: &EditorStyle,
|
style: &EditorStyle,
|
||||||
last_used_color: &mut Option<(PlayerColor, Oid)>,
|
last_used_color: &mut Option<(PlayerColor, Oid)>,
|
||||||
editor: View<Editor>,
|
editor: View<Editor>,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) -> AnyElement {
|
) -> AnyElement {
|
||||||
let mut sha_color = cx
|
let mut sha_color = cx
|
||||||
.theme()
|
.theme()
|
||||||
|
@ -5221,7 +5221,7 @@ fn deploy_blame_entry_context_menu(
|
||||||
details: Option<&CommitDetails>,
|
details: Option<&CommitDetails>,
|
||||||
editor: View<Editor>,
|
editor: View<Editor>,
|
||||||
position: gpui::Point<Pixels>,
|
position: gpui::Point<Pixels>,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) {
|
) {
|
||||||
let context_menu = ContextMenu::build(cx, move |menu, _| {
|
let context_menu = ContextMenu::build(cx, move |menu, _| {
|
||||||
let sha = format!("{}", blame_entry.sha);
|
let sha = format!("{}", blame_entry.sha);
|
||||||
|
|
|
@ -266,7 +266,7 @@ pub fn update_inlay_link_and_hover_points(
|
||||||
editor: &mut Editor,
|
editor: &mut Editor,
|
||||||
secondary_held: bool,
|
secondary_held: bool,
|
||||||
shift_held: bool,
|
shift_held: bool,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
let hovered_offset = if point_for_position.column_overshoot_after_line_end == 0 {
|
let hovered_offset = if point_for_position.column_overshoot_after_line_end == 0 {
|
||||||
Some(snapshot.display_point_to_inlay_offset(point_for_position.exact_unclipped, Bias::Left))
|
Some(snapshot.display_point_to_inlay_offset(point_for_position.exact_unclipped, Bias::Left))
|
||||||
|
|
|
@ -365,7 +365,7 @@ impl Editor {
|
||||||
&mut self,
|
&mut self,
|
||||||
diff_base_buffer: Option<Model<Buffer>>,
|
diff_base_buffer: Option<Model<Buffer>>,
|
||||||
hunk: &HoveredHunk,
|
hunk: &HoveredHunk,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
let buffer = self.buffer.clone();
|
let buffer = self.buffer.clone();
|
||||||
let multi_buffer_snapshot = buffer.read(cx).snapshot(cx);
|
let multi_buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||||
|
@ -454,7 +454,7 @@ impl Editor {
|
||||||
fn apply_diff_hunks_in_range(
|
fn apply_diff_hunks_in_range(
|
||||||
&mut self,
|
&mut self,
|
||||||
range: Range<Anchor>,
|
range: Range<Anchor>,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
let (buffer, range, _) = self
|
let (buffer, range, _) = self
|
||||||
.buffer
|
.buffer
|
||||||
|
@ -530,7 +530,7 @@ impl Editor {
|
||||||
fn hunk_header_block(
|
fn hunk_header_block(
|
||||||
&self,
|
&self,
|
||||||
hunk: &HoveredHunk,
|
hunk: &HoveredHunk,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> BlockProperties<Anchor> {
|
) -> BlockProperties<Anchor> {
|
||||||
let is_branch_buffer = self
|
let is_branch_buffer = self
|
||||||
.buffer
|
.buffer
|
||||||
|
@ -801,7 +801,7 @@ impl Editor {
|
||||||
hunk: &HoveredHunk,
|
hunk: &HoveredHunk,
|
||||||
diff_base_buffer: Model<Buffer>,
|
diff_base_buffer: Model<Buffer>,
|
||||||
deleted_text_height: u32,
|
deleted_text_height: u32,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> BlockProperties<Anchor> {
|
) -> BlockProperties<Anchor> {
|
||||||
let gutter_color = match hunk.status {
|
let gutter_color = match hunk.status {
|
||||||
DiffHunkStatus::Added => unreachable!(),
|
DiffHunkStatus::Added => unreachable!(),
|
||||||
|
@ -864,7 +864,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn clear_expanded_diff_hunks(&mut self, cx: &mut ViewContext<'_, Editor>) -> bool {
|
pub(super) fn clear_expanded_diff_hunks(&mut self, cx: &mut ViewContext<Editor>) -> bool {
|
||||||
if self.diff_map.expand_all {
|
if self.diff_map.expand_all {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -887,7 +887,7 @@ impl Editor {
|
||||||
pub(super) fn sync_expanded_diff_hunks(
|
pub(super) fn sync_expanded_diff_hunks(
|
||||||
diff_map: &mut DiffMap,
|
diff_map: &mut DiffMap,
|
||||||
buffer_id: BufferId,
|
buffer_id: BufferId,
|
||||||
cx: &mut ViewContext<'_, Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
let diff_base_state = diff_map.diff_bases.get_mut(&buffer_id);
|
let diff_base_state = diff_map.diff_bases.get_mut(&buffer_id);
|
||||||
let mut diff_base_buffer = None;
|
let mut diff_base_buffer = None;
|
||||||
|
@ -1134,7 +1134,7 @@ fn editor_with_deleted_text(
|
||||||
diff_base_buffer: Model<Buffer>,
|
diff_base_buffer: Model<Buffer>,
|
||||||
deleted_color: Hsla,
|
deleted_color: Hsla,
|
||||||
hunk: &HoveredHunk,
|
hunk: &HoveredHunk,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> (u32, View<Editor>) {
|
) -> (u32, View<Editor>) {
|
||||||
let parent_editor = cx.view().downgrade();
|
let parent_editor = cx.view().downgrade();
|
||||||
let editor = cx.new_view(|cx| {
|
let editor = cx.new_view(|cx| {
|
||||||
|
|
|
@ -579,7 +579,7 @@ impl InlayHintCache {
|
||||||
buffer_id: BufferId,
|
buffer_id: BufferId,
|
||||||
excerpt_id: ExcerptId,
|
excerpt_id: ExcerptId,
|
||||||
id: InlayId,
|
id: InlayId,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
if let Some(excerpt_hints) = self.hints.get(&excerpt_id) {
|
if let Some(excerpt_hints) = self.hints.get(&excerpt_id) {
|
||||||
let mut guard = excerpt_hints.write();
|
let mut guard = excerpt_hints.write();
|
||||||
|
@ -640,7 +640,7 @@ fn spawn_new_update_tasks(
|
||||||
excerpts_to_query: HashMap<ExcerptId, (Model<Buffer>, Global, Range<usize>)>,
|
excerpts_to_query: HashMap<ExcerptId, (Model<Buffer>, Global, Range<usize>)>,
|
||||||
invalidate: InvalidationStrategy,
|
invalidate: InvalidationStrategy,
|
||||||
update_cache_version: usize,
|
update_cache_version: usize,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
for (excerpt_id, (excerpt_buffer, new_task_buffer_version, excerpt_visible_range)) in
|
for (excerpt_id, (excerpt_buffer, new_task_buffer_version, excerpt_visible_range)) in
|
||||||
excerpts_to_query
|
excerpts_to_query
|
||||||
|
@ -797,7 +797,7 @@ fn new_update_task(
|
||||||
query: ExcerptQuery,
|
query: ExcerptQuery,
|
||||||
query_ranges: QueryRanges,
|
query_ranges: QueryRanges,
|
||||||
excerpt_buffer: Model<Buffer>,
|
excerpt_buffer: Model<Buffer>,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> Task<()> {
|
) -> Task<()> {
|
||||||
cx.spawn(move |editor, mut cx| async move {
|
cx.spawn(move |editor, mut cx| async move {
|
||||||
let visible_range_update_results = future::join_all(
|
let visible_range_update_results = future::join_all(
|
||||||
|
@ -1129,7 +1129,7 @@ fn apply_hint_update(
|
||||||
invalidate: bool,
|
invalidate: bool,
|
||||||
buffer_snapshot: BufferSnapshot,
|
buffer_snapshot: BufferSnapshot,
|
||||||
multi_buffer_snapshot: MultiBufferSnapshot,
|
multi_buffer_snapshot: MultiBufferSnapshot,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
let cached_excerpt_hints = editor
|
let cached_excerpt_hints = editor
|
||||||
.inlay_hint_cache
|
.inlay_hint_cache
|
||||||
|
@ -3434,7 +3434,7 @@ pub mod tests {
|
||||||
labels
|
labels
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn visible_hint_labels(editor: &Editor, cx: &ViewContext<'_, Editor>) -> Vec<String> {
|
pub fn visible_hint_labels(editor: &Editor, cx: &ViewContext<Editor>) -> Vec<String> {
|
||||||
let mut hints = editor
|
let mut hints = editor
|
||||||
.visible_inlay_hints(cx)
|
.visible_inlay_hints(cx)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub fn apply_related_actions(editor: &View<Editor>, cx: &mut WindowContext) {
|
||||||
pub fn expand_macro_recursively(
|
pub fn expand_macro_recursively(
|
||||||
editor: &mut Editor,
|
editor: &mut Editor,
|
||||||
_: &ExpandMacroRecursively,
|
_: &ExpandMacroRecursively,
|
||||||
cx: &mut ViewContext<'_, Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
if editor.selections.count() == 0 {
|
if editor.selections.count() == 0 {
|
||||||
return;
|
return;
|
||||||
|
@ -98,7 +98,7 @@ pub fn expand_macro_recursively(
|
||||||
.detach_and_log_err(cx);
|
.detach_and_log_err(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open_docs(editor: &mut Editor, _: &OpenDocs, cx: &mut ViewContext<'_, Editor>) {
|
pub fn open_docs(editor: &mut Editor, _: &OpenDocs, cx: &mut ViewContext<Editor>) {
|
||||||
if editor.selections.count() == 0 {
|
if editor.selections.count() == 0 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use workspace::Workspace;
|
||||||
|
|
||||||
fn task_context_with_editor(
|
fn task_context_with_editor(
|
||||||
editor: &mut Editor,
|
editor: &mut Editor,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) -> AsyncTask<Option<TaskContext>> {
|
) -> AsyncTask<Option<TaskContext>> {
|
||||||
let Some(project) = editor.project.clone() else {
|
let Some(project) = editor.project.clone() else {
|
||||||
return AsyncTask::ready(None);
|
return AsyncTask::ready(None);
|
||||||
|
@ -74,7 +74,7 @@ fn task_context_with_editor(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn task_context(workspace: &Workspace, cx: &mut WindowContext<'_>) -> AsyncTask<TaskContext> {
|
pub fn task_context(workspace: &Workspace, cx: &mut WindowContext) -> AsyncTask<TaskContext> {
|
||||||
let Some(editor) = workspace
|
let Some(editor) = workspace
|
||||||
.active_item(cx)
|
.active_item(cx)
|
||||||
.and_then(|item| item.act_as::<Editor>(cx))
|
.and_then(|item| item.act_as::<Editor>(cx))
|
||||||
|
|
|
@ -843,7 +843,7 @@ impl ExtensionsPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_extensions_debounced(&mut self, cx: &mut ViewContext<'_, ExtensionsPage>) {
|
fn fetch_extensions_debounced(&mut self, cx: &mut ViewContext<ExtensionsPage>) {
|
||||||
self.extension_fetch_task = Some(cx.spawn(|this, mut cx| async move {
|
self.extension_fetch_task = Some(cx.spawn(|this, mut cx| async move {
|
||||||
let search = this
|
let search = this
|
||||||
.update(&mut cx, |this, cx| this.search_query(cx))
|
.update(&mut cx, |this, cx| this.search_query(cx))
|
||||||
|
|
|
@ -884,7 +884,7 @@ impl FileFinderDelegate {
|
||||||
fn lookup_absolute_path(
|
fn lookup_absolute_path(
|
||||||
&self,
|
&self,
|
||||||
query: FileSearchQuery,
|
query: FileSearchQuery,
|
||||||
cx: &mut ViewContext<'_, Picker<Self>>,
|
cx: &mut ViewContext<Picker<Self>>,
|
||||||
) -> Task<()> {
|
) -> Task<()> {
|
||||||
cx.spawn(|picker, mut cx| async move {
|
cx.spawn(|picker, mut cx| async move {
|
||||||
let Some(project) = picker
|
let Some(project) = picker
|
||||||
|
|
|
@ -1044,7 +1044,7 @@ impl GitPanel {
|
||||||
hunks: Rc<OnceCell<Vec<DiffHunk>>>,
|
hunks: Rc<OnceCell<Vec<DiffHunk>>>,
|
||||||
change_focus: bool,
|
change_focus: bool,
|
||||||
debounce: Option<Duration>,
|
debounce: Option<Duration>,
|
||||||
cx: &mut ViewContext<'_, Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
let workspace = self.workspace.clone();
|
let workspace = self.workspace.clone();
|
||||||
let Some(diff_editor) = self.git_diff_editor.clone() else {
|
let Some(diff_editor) = self.git_diff_editor.clone() else {
|
||||||
|
|
|
@ -1490,7 +1490,7 @@ impl Context for AppContext {
|
||||||
|
|
||||||
fn update_window<T, F>(&mut self, handle: AnyWindowHandle, update: F) -> Result<T>
|
fn update_window<T, F>(&mut self, handle: AnyWindowHandle, update: F) -> Result<T>
|
||||||
where
|
where
|
||||||
F: FnOnce(AnyView, &mut WindowContext<'_>) -> T,
|
F: FnOnce(AnyView, &mut WindowContext) -> T,
|
||||||
{
|
{
|
||||||
self.update(|cx| {
|
self.update(|cx| {
|
||||||
let mut window = cx
|
let mut window = cx
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl Context for AsyncAppContext {
|
||||||
|
|
||||||
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
|
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
|
||||||
where
|
where
|
||||||
F: FnOnce(AnyView, &mut WindowContext<'_>) -> T,
|
F: FnOnce(AnyView, &mut WindowContext) -> T,
|
||||||
{
|
{
|
||||||
let app = self.app.upgrade().context("app was released")?;
|
let app = self.app.upgrade().context("app was released")?;
|
||||||
let mut lock = app.borrow_mut();
|
let mut lock = app.borrow_mut();
|
||||||
|
@ -349,7 +349,7 @@ impl Context for AsyncWindowContext {
|
||||||
|
|
||||||
fn update_window<T, F>(&mut self, window: AnyWindowHandle, update: F) -> Result<T>
|
fn update_window<T, F>(&mut self, window: AnyWindowHandle, update: F) -> Result<T>
|
||||||
where
|
where
|
||||||
F: FnOnce(AnyView, &mut WindowContext<'_>) -> T,
|
F: FnOnce(AnyView, &mut WindowContext) -> T,
|
||||||
{
|
{
|
||||||
self.app.update_window(window, update)
|
self.app.update_window(window, update)
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ impl Context for AsyncWindowContext {
|
||||||
impl VisualContext for AsyncWindowContext {
|
impl VisualContext for AsyncWindowContext {
|
||||||
fn new_view<V>(
|
fn new_view<V>(
|
||||||
&mut self,
|
&mut self,
|
||||||
build_view_state: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
build_view_state: impl FnOnce(&mut ViewContext<V>) -> V,
|
||||||
) -> Self::Result<View<V>>
|
) -> Self::Result<View<V>>
|
||||||
where
|
where
|
||||||
V: 'static + Render,
|
V: 'static + Render,
|
||||||
|
@ -381,7 +381,7 @@ impl VisualContext for AsyncWindowContext {
|
||||||
fn update_view<V: 'static, R>(
|
fn update_view<V: 'static, R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
view: &View<V>,
|
view: &View<V>,
|
||||||
update: impl FnOnce(&mut V, &mut ViewContext<'_, V>) -> R,
|
update: impl FnOnce(&mut V, &mut ViewContext<V>) -> R,
|
||||||
) -> Self::Result<R> {
|
) -> Self::Result<R> {
|
||||||
self.window
|
self.window
|
||||||
.update(self, |_, cx| cx.update_view(view, update))
|
.update(self, |_, cx| cx.update_view(view, update))
|
||||||
|
@ -389,7 +389,7 @@ impl VisualContext for AsyncWindowContext {
|
||||||
|
|
||||||
fn replace_root_view<V>(
|
fn replace_root_view<V>(
|
||||||
&mut self,
|
&mut self,
|
||||||
build_view: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
build_view: impl FnOnce(&mut ViewContext<V>) -> V,
|
||||||
) -> Self::Result<View<V>>
|
) -> Self::Result<View<V>>
|
||||||
where
|
where
|
||||||
V: 'static + Render,
|
V: 'static + Render,
|
||||||
|
|
|
@ -263,7 +263,7 @@ impl<'a, T> Context for ModelContext<'a, T> {
|
||||||
|
|
||||||
fn update_window<R, F>(&mut self, window: AnyWindowHandle, update: F) -> Result<R>
|
fn update_window<R, F>(&mut self, window: AnyWindowHandle, update: F) -> Result<R>
|
||||||
where
|
where
|
||||||
F: FnOnce(AnyView, &mut WindowContext<'_>) -> R,
|
F: FnOnce(AnyView, &mut WindowContext) -> R,
|
||||||
{
|
{
|
||||||
self.app.update_window(window, update)
|
self.app.update_window(window, update)
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl Context for TestAppContext {
|
||||||
|
|
||||||
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
|
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
|
||||||
where
|
where
|
||||||
F: FnOnce(AnyView, &mut WindowContext<'_>) -> T,
|
F: FnOnce(AnyView, &mut WindowContext) -> T,
|
||||||
{
|
{
|
||||||
let mut lock = self.app.borrow_mut();
|
let mut lock = self.app.borrow_mut();
|
||||||
lock.update_window(window, f)
|
lock.update_window(window, f)
|
||||||
|
@ -916,7 +916,7 @@ impl Context for VisualTestContext {
|
||||||
|
|
||||||
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
|
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
|
||||||
where
|
where
|
||||||
F: FnOnce(AnyView, &mut WindowContext<'_>) -> T,
|
F: FnOnce(AnyView, &mut WindowContext) -> T,
|
||||||
{
|
{
|
||||||
self.cx.update_window(window, f)
|
self.cx.update_window(window, f)
|
||||||
}
|
}
|
||||||
|
@ -936,7 +936,7 @@ impl Context for VisualTestContext {
|
||||||
impl VisualContext for VisualTestContext {
|
impl VisualContext for VisualTestContext {
|
||||||
fn new_view<V>(
|
fn new_view<V>(
|
||||||
&mut self,
|
&mut self,
|
||||||
build_view: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
build_view: impl FnOnce(&mut ViewContext<V>) -> V,
|
||||||
) -> Self::Result<View<V>>
|
) -> Self::Result<View<V>>
|
||||||
where
|
where
|
||||||
V: 'static + Render,
|
V: 'static + Render,
|
||||||
|
@ -949,7 +949,7 @@ impl VisualContext for VisualTestContext {
|
||||||
fn update_view<V: 'static, R>(
|
fn update_view<V: 'static, R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
view: &View<V>,
|
view: &View<V>,
|
||||||
update: impl FnOnce(&mut V, &mut ViewContext<'_, V>) -> R,
|
update: impl FnOnce(&mut V, &mut ViewContext<V>) -> R,
|
||||||
) -> Self::Result<R> {
|
) -> Self::Result<R> {
|
||||||
self.window
|
self.window
|
||||||
.update(&mut self.cx, |_, cx| cx.update_view(view, update))
|
.update(&mut self.cx, |_, cx| cx.update_view(view, update))
|
||||||
|
@ -958,7 +958,7 @@ impl VisualContext for VisualTestContext {
|
||||||
|
|
||||||
fn replace_root_view<V>(
|
fn replace_root_view<V>(
|
||||||
&mut self,
|
&mut self,
|
||||||
build_view: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
build_view: impl FnOnce(&mut ViewContext<V>) -> V,
|
||||||
) -> Self::Result<View<V>>
|
) -> Self::Result<View<V>>
|
||||||
where
|
where
|
||||||
V: 'static + Render,
|
V: 'static + Render,
|
||||||
|
@ -993,7 +993,7 @@ impl AnyWindowHandle {
|
||||||
pub fn build_view<V: Render + 'static>(
|
pub fn build_view<V: Render + 'static>(
|
||||||
&self,
|
&self,
|
||||||
cx: &mut TestAppContext,
|
cx: &mut TestAppContext,
|
||||||
build_view: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
build_view: impl FnOnce(&mut ViewContext<V>) -> V,
|
||||||
) -> View<V> {
|
) -> View<V> {
|
||||||
self.update(cx, |_, cx| cx.new_view(build_view)).unwrap()
|
self.update(cx, |_, cx| cx.new_view(build_view)).unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -2499,7 +2499,7 @@ impl ScrollAnchor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Request scroll to this item on the next frame.
|
/// Request scroll to this item on the next frame.
|
||||||
pub fn scroll_to(&self, cx: &mut WindowContext<'_>) {
|
pub fn scroll_to(&self, cx: &mut WindowContext) {
|
||||||
let this = self.clone();
|
let this = self.clone();
|
||||||
|
|
||||||
cx.on_next_frame(move |_| {
|
cx.on_next_frame(move |_| {
|
||||||
|
|
|
@ -472,9 +472,9 @@ pub struct InteractiveText {
|
||||||
element_id: ElementId,
|
element_id: ElementId,
|
||||||
text: StyledText,
|
text: StyledText,
|
||||||
click_listener:
|
click_listener:
|
||||||
Option<Box<dyn Fn(&[Range<usize>], InteractiveTextClickEvent, &mut WindowContext<'_>)>>,
|
Option<Box<dyn Fn(&[Range<usize>], InteractiveTextClickEvent, &mut WindowContext)>>,
|
||||||
hover_listener: Option<Box<dyn Fn(Option<usize>, MouseMoveEvent, &mut WindowContext<'_>)>>,
|
hover_listener: Option<Box<dyn Fn(Option<usize>, MouseMoveEvent, &mut WindowContext)>>,
|
||||||
tooltip_builder: Option<Rc<dyn Fn(usize, &mut WindowContext<'_>) -> Option<AnyView>>>,
|
tooltip_builder: Option<Rc<dyn Fn(usize, &mut WindowContext) -> Option<AnyView>>>,
|
||||||
clickable_ranges: Vec<Range<usize>>,
|
clickable_ranges: Vec<Range<usize>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ impl InteractiveText {
|
||||||
pub fn on_click(
|
pub fn on_click(
|
||||||
mut self,
|
mut self,
|
||||||
ranges: Vec<Range<usize>>,
|
ranges: Vec<Range<usize>>,
|
||||||
listener: impl Fn(usize, &mut WindowContext<'_>) + 'static,
|
listener: impl Fn(usize, &mut WindowContext) + 'static,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.click_listener = Some(Box::new(move |ranges, event, cx| {
|
self.click_listener = Some(Box::new(move |ranges, event, cx| {
|
||||||
for (range_ix, range) in ranges.iter().enumerate() {
|
for (range_ix, range) in ranges.iter().enumerate() {
|
||||||
|
@ -528,7 +528,7 @@ impl InteractiveText {
|
||||||
/// index of the hovered character, or None if the mouse leaves the text.
|
/// index of the hovered character, or None if the mouse leaves the text.
|
||||||
pub fn on_hover(
|
pub fn on_hover(
|
||||||
mut self,
|
mut self,
|
||||||
listener: impl Fn(Option<usize>, MouseMoveEvent, &mut WindowContext<'_>) + 'static,
|
listener: impl Fn(Option<usize>, MouseMoveEvent, &mut WindowContext) + 'static,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.hover_listener = Some(Box::new(listener));
|
self.hover_listener = Some(Box::new(listener));
|
||||||
self
|
self
|
||||||
|
@ -537,7 +537,7 @@ impl InteractiveText {
|
||||||
/// tooltip lets you specify a tooltip for a given character index in the string.
|
/// tooltip lets you specify a tooltip for a given character index in the string.
|
||||||
pub fn tooltip(
|
pub fn tooltip(
|
||||||
mut self,
|
mut self,
|
||||||
builder: impl Fn(usize, &mut WindowContext<'_>) -> Option<AnyView> + 'static,
|
builder: impl Fn(usize, &mut WindowContext) -> Option<AnyView> + 'static,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.tooltip_builder = Some(Rc::new(builder));
|
self.tooltip_builder = Some(Rc::new(builder));
|
||||||
self
|
self
|
||||||
|
|
|
@ -202,7 +202,7 @@ pub trait Context {
|
||||||
/// Update a window for the given handle.
|
/// Update a window for the given handle.
|
||||||
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
|
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
|
||||||
where
|
where
|
||||||
F: FnOnce(AnyView, &mut WindowContext<'_>) -> T;
|
F: FnOnce(AnyView, &mut WindowContext) -> T;
|
||||||
|
|
||||||
/// Read a window off of the application context.
|
/// Read a window off of the application context.
|
||||||
fn read_window<T, R>(
|
fn read_window<T, R>(
|
||||||
|
@ -231,7 +231,7 @@ pub trait VisualContext: Context {
|
||||||
/// Construct a new view in the window referenced by this context.
|
/// Construct a new view in the window referenced by this context.
|
||||||
fn new_view<V>(
|
fn new_view<V>(
|
||||||
&mut self,
|
&mut self,
|
||||||
build_view: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
build_view: impl FnOnce(&mut ViewContext<V>) -> V,
|
||||||
) -> Self::Result<View<V>>
|
) -> Self::Result<View<V>>
|
||||||
where
|
where
|
||||||
V: 'static + Render;
|
V: 'static + Render;
|
||||||
|
@ -240,13 +240,13 @@ pub trait VisualContext: Context {
|
||||||
fn update_view<V: 'static, R>(
|
fn update_view<V: 'static, R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
view: &View<V>,
|
view: &View<V>,
|
||||||
update: impl FnOnce(&mut V, &mut ViewContext<'_, V>) -> R,
|
update: impl FnOnce(&mut V, &mut ViewContext<V>) -> R,
|
||||||
) -> Self::Result<R>;
|
) -> Self::Result<R>;
|
||||||
|
|
||||||
/// Replace the root view of a window with a new view.
|
/// Replace the root view of a window with a new view.
|
||||||
fn replace_root_view<V>(
|
fn replace_root_view<V>(
|
||||||
&mut self,
|
&mut self,
|
||||||
build_view: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
build_view: impl FnOnce(&mut ViewContext<V>) -> V,
|
||||||
) -> Self::Result<View<V>>
|
) -> Self::Result<View<V>>
|
||||||
where
|
where
|
||||||
V: 'static + Render;
|
V: 'static + Render;
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl<V: 'static> View<V> {
|
||||||
pub fn update<C, R>(
|
pub fn update<C, R>(
|
||||||
&self,
|
&self,
|
||||||
cx: &mut C,
|
cx: &mut C,
|
||||||
f: impl FnOnce(&mut V, &mut ViewContext<'_, V>) -> R,
|
f: impl FnOnce(&mut V, &mut ViewContext<V>) -> R,
|
||||||
) -> C::Result<R>
|
) -> C::Result<R>
|
||||||
where
|
where
|
||||||
C: VisualContext,
|
C: VisualContext,
|
||||||
|
@ -183,7 +183,7 @@ impl<V: 'static> WeakView<V> {
|
||||||
pub fn update<C, R>(
|
pub fn update<C, R>(
|
||||||
&self,
|
&self,
|
||||||
cx: &mut C,
|
cx: &mut C,
|
||||||
f: impl FnOnce(&mut V, &mut ViewContext<'_, V>) -> R,
|
f: impl FnOnce(&mut V, &mut ViewContext<V>) -> R,
|
||||||
) -> Result<R>
|
) -> Result<R>
|
||||||
where
|
where
|
||||||
C: VisualContext,
|
C: VisualContext,
|
||||||
|
|
|
@ -703,15 +703,11 @@ impl LspLogView {
|
||||||
});
|
});
|
||||||
let editor_subscription = cx.subscribe(
|
let editor_subscription = cx.subscribe(
|
||||||
&editor,
|
&editor,
|
||||||
|_, _, event: &EditorEvent, cx: &mut ViewContext<'_, LspLogView>| {
|
|_, _, event: &EditorEvent, cx: &mut ViewContext<LspLogView>| cx.emit(event.clone()),
|
||||||
cx.emit(event.clone())
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
let search_subscription = cx.subscribe(
|
let search_subscription = cx.subscribe(
|
||||||
&editor,
|
&editor,
|
||||||
|_, _, event: &SearchEvent, cx: &mut ViewContext<'_, LspLogView>| {
|
|_, _, event: &SearchEvent, cx: &mut ViewContext<LspLogView>| cx.emit(event.clone()),
|
||||||
cx.emit(event.clone())
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
(editor, vec![editor_subscription, search_subscription])
|
(editor, vec![editor_subscription, search_subscription])
|
||||||
}
|
}
|
||||||
|
@ -730,15 +726,11 @@ impl LspLogView {
|
||||||
});
|
});
|
||||||
let editor_subscription = cx.subscribe(
|
let editor_subscription = cx.subscribe(
|
||||||
&editor,
|
&editor,
|
||||||
|_, _, event: &EditorEvent, cx: &mut ViewContext<'_, LspLogView>| {
|
|_, _, event: &EditorEvent, cx: &mut ViewContext<LspLogView>| cx.emit(event.clone()),
|
||||||
cx.emit(event.clone())
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
let search_subscription = cx.subscribe(
|
let search_subscription = cx.subscribe(
|
||||||
&editor,
|
&editor,
|
||||||
|_, _, event: &SearchEvent, cx: &mut ViewContext<'_, LspLogView>| {
|
|_, _, event: &SearchEvent, cx: &mut ViewContext<LspLogView>| cx.emit(event.clone()),
|
||||||
cx.emit(event.clone())
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
(editor, vec![editor_subscription, search_subscription])
|
(editor, vec![editor_subscription, search_subscription])
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,7 +273,7 @@ impl SyntaxTreeView {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for SyntaxTreeView {
|
impl Render for SyntaxTreeView {
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> impl IntoElement {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
|
||||||
let mut rendered = div().flex_1();
|
let mut rendered = div().flex_1();
|
||||||
|
|
||||||
if let Some(layer) = self
|
if let Some(layer) = self
|
||||||
|
@ -422,7 +422,7 @@ impl SyntaxTreeToolbarItemView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_menu(&mut self, cx: &mut ViewContext<'_, Self>) -> Option<PopoverMenu<ContextMenu>> {
|
fn render_menu(&mut self, cx: &mut ViewContext<Self>) -> Option<PopoverMenu<ContextMenu>> {
|
||||||
let tree_view = self.tree_view.as_ref()?;
|
let tree_view = self.tree_view.as_ref()?;
|
||||||
let tree_view = tree_view.read(cx);
|
let tree_view = tree_view.read(cx);
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ fn format_node_range(node: Node) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for SyntaxTreeToolbarItemView {
|
impl Render for SyntaxTreeToolbarItemView {
|
||||||
fn render(&mut self, cx: &mut ViewContext<'_, Self>) -> impl IntoElement {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||||
self.render_menu(cx)
|
self.render_menu(cx)
|
||||||
.unwrap_or_else(|| PopoverMenu::new("Empty Syntax Tree"))
|
.unwrap_or_else(|| PopoverMenu::new("Empty Syntax Tree"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ impl SearchState {
|
||||||
previous_matches: HashMap<Range<editor::Anchor>, Arc<OnceLock<SearchData>>>,
|
previous_matches: HashMap<Range<editor::Anchor>, Arc<OnceLock<SearchData>>>,
|
||||||
new_matches: Vec<Range<editor::Anchor>>,
|
new_matches: Vec<Range<editor::Anchor>>,
|
||||||
theme: Arc<SyntaxTheme>,
|
theme: Arc<SyntaxTheme>,
|
||||||
cx: &mut ViewContext<'_, OutlinePanel>,
|
cx: &mut ViewContext<OutlinePanel>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let (highlight_search_match_tx, highlight_search_match_rx) = channel::unbounded();
|
let (highlight_search_match_tx, highlight_search_match_rx) = channel::unbounded();
|
||||||
let (notify_tx, notify_rx) = channel::unbounded::<()>();
|
let (notify_tx, notify_rx) = channel::unbounded::<()>();
|
||||||
|
@ -1661,7 +1661,7 @@ impl OutlinePanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reveal_entry_for_selection(&mut self, editor: View<Editor>, cx: &mut ViewContext<'_, Self>) {
|
fn reveal_entry_for_selection(&mut self, editor: View<Editor>, cx: &mut ViewContext<Self>) {
|
||||||
if !self.active || !OutlinePanelSettings::get_global(cx).auto_reveal_entries {
|
if !self.active || !OutlinePanelSettings::get_global(cx).auto_reveal_entries {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2656,7 +2656,7 @@ impl OutlinePanel {
|
||||||
self.clear_previous(cx);
|
self.clear_previous(cx);
|
||||||
let buffer_search_subscription = cx.subscribe(
|
let buffer_search_subscription = cx.subscribe(
|
||||||
&new_active_editor,
|
&new_active_editor,
|
||||||
|outline_panel: &mut Self, _, e: &SearchEvent, cx: &mut ViewContext<'_, Self>| {
|
|outline_panel: &mut Self, _, e: &SearchEvent, cx: &mut ViewContext<Self>| {
|
||||||
if matches!(e, SearchEvent::MatchesInvalidated) {
|
if matches!(e, SearchEvent::MatchesInvalidated) {
|
||||||
outline_panel.update_search_matches(cx);
|
outline_panel.update_search_matches(cx);
|
||||||
};
|
};
|
||||||
|
@ -2675,7 +2675,7 @@ impl OutlinePanel {
|
||||||
self.update_fs_entries(new_active_editor, None, cx);
|
self.update_fs_entries(new_active_editor, None, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_previous(&mut self, cx: &mut WindowContext<'_>) {
|
fn clear_previous(&mut self, cx: &mut WindowContext) {
|
||||||
self.fs_entries_update_task = Task::ready(());
|
self.fs_entries_update_task = Task::ready(());
|
||||||
self.outline_fetch_tasks.clear();
|
self.outline_fetch_tasks.clear();
|
||||||
self.cached_entries_update_task = Task::ready(());
|
self.cached_entries_update_task = Task::ready(());
|
||||||
|
@ -3124,7 +3124,7 @@ impl OutlinePanel {
|
||||||
&self,
|
&self,
|
||||||
is_singleton: bool,
|
is_singleton: bool,
|
||||||
query: Option<String>,
|
query: Option<String>,
|
||||||
cx: &mut ViewContext<'_, Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Task<(Vec<CachedEntry>, Option<usize>)> {
|
) -> Task<(Vec<CachedEntry>, Option<usize>)> {
|
||||||
let project = self.project.clone();
|
let project = self.project.clone();
|
||||||
let Some(active_editor) = self.active_editor() else {
|
let Some(active_editor) = self.active_editor() else {
|
||||||
|
@ -4078,7 +4078,7 @@ impl OutlinePanel {
|
||||||
query: Option<String>,
|
query: Option<String>,
|
||||||
show_indent_guides: bool,
|
show_indent_guides: bool,
|
||||||
indent_size: f32,
|
indent_size: f32,
|
||||||
cx: &mut ViewContext<'_, Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Div {
|
) -> Div {
|
||||||
let contents = if self.cached_entries.is_empty() {
|
let contents = if self.cached_entries.is_empty() {
|
||||||
let header = if self.updating_fs_entries {
|
let header = if self.updating_fs_entries {
|
||||||
|
@ -4266,7 +4266,7 @@ impl OutlinePanel {
|
||||||
v_flex().w_full().flex_1().overflow_hidden().child(contents)
|
v_flex().w_full().flex_1().overflow_hidden().child(contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_filter_footer(&mut self, pinned: bool, cx: &mut ViewContext<'_, Self>) -> Div {
|
fn render_filter_footer(&mut self, pinned: bool, cx: &mut ViewContext<Self>) -> Div {
|
||||||
v_flex().flex_none().child(horizontal_separator(cx)).child(
|
v_flex().flex_none().child(horizontal_separator(cx)).child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.p_2()
|
.p_2()
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub(crate) enum Head {
|
||||||
impl Head {
|
impl Head {
|
||||||
pub fn editor<V: 'static>(
|
pub fn editor<V: 'static>(
|
||||||
placeholder_text: Arc<str>,
|
placeholder_text: Arc<str>,
|
||||||
edit_handler: impl FnMut(&mut V, View<Editor>, &EditorEvent, &mut ViewContext<'_, V>) + 'static,
|
edit_handler: impl FnMut(&mut V, View<Editor>, &EditorEvent, &mut ViewContext<V>) + 'static,
|
||||||
cx: &mut ViewContext<V>,
|
cx: &mut ViewContext<V>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let editor = cx.new_view(|cx| {
|
let editor = cx.new_view(|cx| {
|
||||||
|
@ -29,7 +29,7 @@ impl Head {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn empty<V: 'static>(
|
pub fn empty<V: 'static>(
|
||||||
blur_handler: impl FnMut(&mut V, &mut ViewContext<'_, V>) + 'static,
|
blur_handler: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
|
||||||
cx: &mut ViewContext<V>,
|
cx: &mut ViewContext<V>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let head = cx.new_view(EmptyHead::new);
|
let head = cx.new_view(EmptyHead::new);
|
||||||
|
|
|
@ -425,7 +425,7 @@ impl<D: PickerDelegate> Picker<D> {
|
||||||
self.cancel(&menu::Cancel, cx);
|
self.cancel(&menu::Cancel, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh_placeholder(&mut self, cx: &mut WindowContext<'_>) {
|
pub fn refresh_placeholder(&mut self, cx: &mut WindowContext) {
|
||||||
match &self.head {
|
match &self.head {
|
||||||
Head::Editor(view) => {
|
Head::Editor(view) => {
|
||||||
let placeholder = self.delegate.placeholder_text(cx);
|
let placeholder = self.delegate.placeholder_text(cx);
|
||||||
|
@ -493,7 +493,7 @@ impl<D: PickerDelegate> Picker<D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_query(&self, query: impl Into<Arc<str>>, cx: &mut WindowContext<'_>) {
|
pub fn set_query(&self, query: impl Into<Arc<str>>, cx: &mut WindowContext) {
|
||||||
if let Head::Editor(ref editor) = &self.head {
|
if let Head::Editor(ref editor) = &self.head {
|
||||||
editor.update(cx, |editor, cx| {
|
editor.update(cx, |editor, cx| {
|
||||||
editor.set_text(query, cx);
|
editor.set_text(query, cx);
|
||||||
|
|
|
@ -1209,7 +1209,7 @@ impl ProjectPanel {
|
||||||
self.remove(false, action.skip_prompt, cx);
|
self.remove(false, action.skip_prompt, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove(&mut self, trash: bool, skip_prompt: bool, cx: &mut ViewContext<'_, ProjectPanel>) {
|
fn remove(&mut self, trash: bool, skip_prompt: bool, cx: &mut ViewContext<ProjectPanel>) {
|
||||||
maybe!({
|
maybe!({
|
||||||
let items_to_delete = self.disjoint_entries(cx);
|
let items_to_delete = self.disjoint_entries(cx);
|
||||||
if items_to_delete.is_empty() {
|
if items_to_delete.is_empty() {
|
||||||
|
@ -3705,7 +3705,7 @@ impl ProjectPanel {
|
||||||
project: Model<Project>,
|
project: Model<Project>,
|
||||||
entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
skip_ignored: bool,
|
skip_ignored: bool,
|
||||||
cx: &mut ViewContext<'_, Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) {
|
if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) {
|
||||||
let worktree = worktree.read(cx);
|
let worktree = worktree.read(cx);
|
||||||
|
|
|
@ -61,7 +61,7 @@ struct CreateRemoteServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CreateRemoteServer {
|
impl CreateRemoteServer {
|
||||||
fn new(cx: &mut WindowContext<'_>) -> Self {
|
fn new(cx: &mut WindowContext) -> Self {
|
||||||
let address_editor = cx.new_view(Editor::single_line);
|
let address_editor = cx.new_view(Editor::single_line);
|
||||||
address_editor.update(cx, |this, cx| {
|
address_editor.update(cx, |this, cx| {
|
||||||
this.focus_handle(cx).focus(cx);
|
this.focus_handle(cx).focus(cx);
|
||||||
|
@ -88,7 +88,7 @@ struct EditNicknameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EditNicknameState {
|
impl EditNicknameState {
|
||||||
fn new(index: usize, cx: &mut WindowContext<'_>) -> Self {
|
fn new(index: usize, cx: &mut WindowContext) -> Self {
|
||||||
let this = Self {
|
let this = Self {
|
||||||
index,
|
index,
|
||||||
editor: cx.new_view(Editor::single_line),
|
editor: cx.new_view(Editor::single_line),
|
||||||
|
@ -264,7 +264,7 @@ struct DefaultState {
|
||||||
servers: Vec<ProjectEntry>,
|
servers: Vec<ProjectEntry>,
|
||||||
}
|
}
|
||||||
impl DefaultState {
|
impl DefaultState {
|
||||||
fn new(cx: &WindowContext<'_>) -> Self {
|
fn new(cx: &WindowContext) -> Self {
|
||||||
let handle = ScrollHandle::new();
|
let handle = ScrollHandle::new();
|
||||||
let scrollbar = ScrollbarState::new(handle.clone());
|
let scrollbar = ScrollbarState::new(handle.clone());
|
||||||
let add_new_server = NavigableEntry::new(&handle, cx);
|
let add_new_server = NavigableEntry::new(&handle, cx);
|
||||||
|
@ -309,7 +309,7 @@ enum Mode {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mode {
|
impl Mode {
|
||||||
fn default_mode(cx: &WindowContext<'_>) -> Self {
|
fn default_mode(cx: &WindowContext) -> Self {
|
||||||
Self::Default(DefaultState::new(cx))
|
Self::Default(DefaultState::new(cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1003,7 +1003,7 @@ impl RemoteServerProjects {
|
||||||
fn callback(
|
fn callback(
|
||||||
workspace: WeakView<Workspace>,
|
workspace: WeakView<Workspace>,
|
||||||
connection_string: SharedString,
|
connection_string: SharedString,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) {
|
) {
|
||||||
cx.write_to_clipboard(ClipboardItem::new_string(
|
cx.write_to_clipboard(ClipboardItem::new_string(
|
||||||
connection_string.to_string(),
|
connection_string.to_string(),
|
||||||
|
@ -1069,7 +1069,7 @@ impl RemoteServerProjects {
|
||||||
remote_servers: View<RemoteServerProjects>,
|
remote_servers: View<RemoteServerProjects>,
|
||||||
index: usize,
|
index: usize,
|
||||||
connection_string: SharedString,
|
connection_string: SharedString,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) {
|
) {
|
||||||
let prompt_message =
|
let prompt_message =
|
||||||
format!("Remove server `{}`?", connection_string);
|
format!("Remove server `{}`?", connection_string);
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ impl ProjectSearchView {
|
||||||
fn buffer_search_query(
|
fn buffer_search_query(
|
||||||
workspace: &mut Workspace,
|
workspace: &mut Workspace,
|
||||||
item: &dyn ItemHandle,
|
item: &dyn ItemHandle,
|
||||||
cx: &mut ViewContext<'_, Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
let buffer_search_bar = workspace
|
let buffer_search_bar = workspace
|
||||||
.pane_for(item)
|
.pane_for(item)
|
||||||
|
|
|
@ -196,7 +196,7 @@ impl ProjectIndexDebugView {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ProjectIndexDebugView {
|
impl Render for ProjectIndexDebugView {
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> impl IntoElement {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
|
||||||
if let Some(selected_path) = self.selected_path.as_ref() {
|
if let Some(selected_path) = self.selected_path.as_ref() {
|
||||||
v_flex()
|
v_flex()
|
||||||
.child(
|
.child(
|
||||||
|
|
|
@ -253,7 +253,7 @@ impl TabSwitcherDelegate {
|
||||||
fn select_item(
|
fn select_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
item_id: EntityId,
|
item_id: EntityId,
|
||||||
cx: &mut ViewContext<'_, Picker<TabSwitcherDelegate>>,
|
cx: &mut ViewContext<Picker<TabSwitcherDelegate>>,
|
||||||
) {
|
) {
|
||||||
let selected_idx = self
|
let selected_idx = self
|
||||||
.matches
|
.matches
|
||||||
|
@ -263,7 +263,7 @@ impl TabSwitcherDelegate {
|
||||||
self.set_selected_index(selected_idx, cx);
|
self.set_selected_index(selected_idx, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close_item_at(&mut self, ix: usize, cx: &mut ViewContext<'_, Picker<TabSwitcherDelegate>>) {
|
fn close_item_at(&mut self, ix: usize, cx: &mut ViewContext<Picker<TabSwitcherDelegate>>) {
|
||||||
let Some(tab_match) = self.matches.get(ix) else {
|
let Some(tab_match) = self.matches.get(ix) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
|
@ -105,7 +105,7 @@ fn spawn_task_or_modal(workspace: &mut Workspace, action: &Spawn, cx: &mut ViewC
|
||||||
fn toggle_modal(
|
fn toggle_modal(
|
||||||
workspace: &mut Workspace,
|
workspace: &mut Workspace,
|
||||||
reveal_target: Option<RevealTarget>,
|
reveal_target: Option<RevealTarget>,
|
||||||
cx: &mut ViewContext<'_, Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) -> AsyncTask<()> {
|
) -> AsyncTask<()> {
|
||||||
let task_store = workspace.project().read(cx).task_store().clone();
|
let task_store = workspace.project().read(cx).task_store().clone();
|
||||||
let workspace_handle = workspace.weak_handle();
|
let workspace_handle = workspace.weak_handle();
|
||||||
|
|
|
@ -143,7 +143,7 @@ fn populate_pane_items(
|
||||||
pane: &mut Pane,
|
pane: &mut Pane,
|
||||||
items: Vec<View<TerminalView>>,
|
items: Vec<View<TerminalView>>,
|
||||||
active_item: Option<u64>,
|
active_item: Option<u64>,
|
||||||
cx: &mut ViewContext<'_, Pane>,
|
cx: &mut ViewContext<Pane>,
|
||||||
) {
|
) {
|
||||||
let mut item_index = pane.items_len();
|
let mut item_index = pane.items_len();
|
||||||
for item in items {
|
for item in items {
|
||||||
|
|
|
@ -867,7 +867,7 @@ impl Element for TerminalElement {
|
||||||
bounds: Bounds<Pixels>,
|
bounds: Bounds<Pixels>,
|
||||||
_: &mut Self::RequestLayoutState,
|
_: &mut Self::RequestLayoutState,
|
||||||
layout: &mut Self::PrepaintState,
|
layout: &mut Self::PrepaintState,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) {
|
) {
|
||||||
cx.with_content_mask(Some(ContentMask { bounds }), |cx| {
|
cx.with_content_mask(Some(ContentMask { bounds }), |cx| {
|
||||||
let scroll_top = self.terminal_view.read(cx).scroll_top;
|
let scroll_top = self.terminal_view.read(cx).scroll_top;
|
||||||
|
|
|
@ -824,7 +824,7 @@ impl TerminalPanel {
|
||||||
task_pane: View<Pane>,
|
task_pane: View<Pane>,
|
||||||
terminal_item_index: usize,
|
terminal_item_index: usize,
|
||||||
terminal_to_replace: View<TerminalView>,
|
terminal_to_replace: View<TerminalView>,
|
||||||
cx: &mut ViewContext<'_, Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Task<Option<()>> {
|
) -> Task<Option<()>> {
|
||||||
let reveal = spawn_task.reveal;
|
let reveal = spawn_task.reveal;
|
||||||
let reveal_target = spawn_task.reveal_target;
|
let reveal_target = spawn_task.reveal_target;
|
||||||
|
@ -1122,7 +1122,7 @@ async fn wait_for_terminals_tasks(
|
||||||
let _: Vec<()> = join_all(pending_tasks).await;
|
let _: Vec<()> = join_all(pending_tasks).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_paths_to_terminal(pane: &mut Pane, paths: &[PathBuf], cx: &mut ViewContext<'_, Pane>) {
|
fn add_paths_to_terminal(pane: &mut Pane, paths: &[PathBuf], cx: &mut ViewContext<Pane>) {
|
||||||
if let Some(terminal_view) = pane
|
if let Some(terminal_view) = pane
|
||||||
.active_item()
|
.active_item()
|
||||||
.and_then(|item| item.downcast::<TerminalView>())
|
.and_then(|item| item.downcast::<TerminalView>())
|
||||||
|
|
|
@ -606,7 +606,7 @@ impl TerminalView {
|
||||||
dispatch_context
|
dispatch_context
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_terminal(&mut self, terminal: Model<Terminal>, cx: &mut ViewContext<'_, TerminalView>) {
|
fn set_terminal(&mut self, terminal: Model<Terminal>, cx: &mut ViewContext<TerminalView>) {
|
||||||
self._terminal_subscriptions =
|
self._terminal_subscriptions =
|
||||||
subscribe_for_terminal_events(&terminal, self.workspace.clone(), cx);
|
subscribe_for_terminal_events(&terminal, self.workspace.clone(), cx);
|
||||||
self.terminal = terminal;
|
self.terminal = terminal;
|
||||||
|
@ -616,7 +616,7 @@ impl TerminalView {
|
||||||
fn subscribe_for_terminal_events(
|
fn subscribe_for_terminal_events(
|
||||||
terminal: &Model<Terminal>,
|
terminal: &Model<Terminal>,
|
||||||
workspace: WeakView<Workspace>,
|
workspace: WeakView<Workspace>,
|
||||||
cx: &mut ViewContext<'_, TerminalView>,
|
cx: &mut ViewContext<TerminalView>,
|
||||||
) -> Vec<Subscription> {
|
) -> Vec<Subscription> {
|
||||||
let terminal_subscription = cx.observe(terminal, |_, _, cx| cx.notify());
|
let terminal_subscription = cx.observe(terminal, |_, _, cx| cx.notify());
|
||||||
let terminal_events_subscription =
|
let terminal_events_subscription =
|
||||||
|
|
|
@ -60,7 +60,7 @@ impl ApplicationMenu {
|
||||||
cleaned
|
cleaned
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_menu_from_items(entry: MenuEntry, cx: &mut WindowContext<'_>) -> View<ContextMenu> {
|
fn build_menu_from_items(entry: MenuEntry, cx: &mut WindowContext) -> View<ContextMenu> {
|
||||||
ContextMenu::build(cx, |menu, cx| {
|
ContextMenu::build(cx, |menu, cx| {
|
||||||
let menu = menu.when_some(cx.focused(), |menu, focused| menu.context(focused));
|
let menu = menu.when_some(cx.focused(), |menu, focused| menu.context(focused));
|
||||||
let sanitized_items = Self::sanitize_menu_items(entry.menu.items);
|
let sanitized_items = Self::sanitize_menu_items(entry.menu.items);
|
||||||
|
@ -150,7 +150,7 @@ impl ApplicationMenu {
|
||||||
|
|
||||||
// Defer to prevent focus race condition with the previously open menu
|
// Defer to prevent focus race condition with the previously open menu
|
||||||
let handle = current_handle.clone();
|
let handle = current_handle.clone();
|
||||||
cx.defer(move |w| handle.show(w));
|
cx.defer(move |cx| handle.show(cx));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,14 @@ pub struct NavigableEntry {
|
||||||
|
|
||||||
impl NavigableEntry {
|
impl NavigableEntry {
|
||||||
/// Creates a new [NavigableEntry] for a given scroll handle.
|
/// Creates a new [NavigableEntry] for a given scroll handle.
|
||||||
pub fn new(scroll_handle: &ScrollHandle, cx: &WindowContext<'_>) -> Self {
|
pub fn new(scroll_handle: &ScrollHandle, cx: &WindowContext) -> Self {
|
||||||
Self {
|
Self {
|
||||||
focus_handle: cx.focus_handle(),
|
focus_handle: cx.focus_handle(),
|
||||||
scroll_anchor: Some(ScrollAnchor::for_handle(scroll_handle.clone())),
|
scroll_anchor: Some(ScrollAnchor::for_handle(scroll_handle.clone())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Create a new [NavigableEntry] that cannot be scrolled to.
|
/// Create a new [NavigableEntry] that cannot be scrolled to.
|
||||||
pub fn focusable(cx: &WindowContext<'_>) -> Self {
|
pub fn focusable(cx: &WindowContext) -> Self {
|
||||||
Self {
|
Self {
|
||||||
focus_handle: cx.focus_handle(),
|
focus_handle: cx.focus_handle(),
|
||||||
scroll_anchor: None,
|
scroll_anchor: None,
|
||||||
|
@ -51,7 +51,7 @@ impl Navigable {
|
||||||
|
|
||||||
fn find_focused(
|
fn find_focused(
|
||||||
selectable_children: &[NavigableEntry],
|
selectable_children: &[NavigableEntry],
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) -> Option<usize> {
|
) -> Option<usize> {
|
||||||
selectable_children
|
selectable_children
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -59,7 +59,7 @@ impl Navigable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl RenderOnce for Navigable {
|
impl RenderOnce for Navigable {
|
||||||
fn render(self, _: &mut WindowContext<'_>) -> impl crate::IntoElement {
|
fn render(self, _: &mut WindowContext) -> impl crate::IntoElement {
|
||||||
div()
|
div()
|
||||||
.on_action({
|
.on_action({
|
||||||
let children = self.selectable_children.clone();
|
let children = self.selectable_children.clone();
|
||||||
|
|
|
@ -1942,7 +1942,7 @@ impl Pane {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_pin_tab(&mut self, _: &TogglePinTab, cx: &mut ViewContext<'_, Self>) {
|
fn toggle_pin_tab(&mut self, _: &TogglePinTab, cx: &mut ViewContext<Self>) {
|
||||||
if self.items.is_empty() {
|
if self.items.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1954,7 +1954,7 @@ impl Pane {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<'_, Self>) {
|
fn pin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<Self>) {
|
||||||
maybe!({
|
maybe!({
|
||||||
let pane = cx.view().clone();
|
let pane = cx.view().clone();
|
||||||
let destination_index = self.pinned_tab_count.min(ix);
|
let destination_index = self.pinned_tab_count.min(ix);
|
||||||
|
@ -1971,7 +1971,7 @@ impl Pane {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unpin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<'_, Self>) {
|
fn unpin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<Self>) {
|
||||||
maybe!({
|
maybe!({
|
||||||
let pane = cx.view().clone();
|
let pane = cx.view().clone();
|
||||||
self.pinned_tab_count = self.pinned_tab_count.checked_sub(1)?;
|
self.pinned_tab_count = self.pinned_tab_count.checked_sub(1)?;
|
||||||
|
@ -2003,7 +2003,7 @@ impl Pane {
|
||||||
item: &dyn ItemHandle,
|
item: &dyn ItemHandle,
|
||||||
detail: usize,
|
detail: usize,
|
||||||
focus_handle: &FocusHandle,
|
focus_handle: &FocusHandle,
|
||||||
cx: &mut ViewContext<'_, Pane>,
|
cx: &mut ViewContext<Pane>,
|
||||||
) -> impl IntoElement {
|
) -> impl IntoElement {
|
||||||
let is_active = ix == self.active_item_index;
|
let is_active = ix == self.active_item_index;
|
||||||
let is_preview = self
|
let is_preview = self
|
||||||
|
@ -2416,7 +2416,7 @@ impl Pane {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl IntoElement {
|
fn render_tab_bar(&mut self, cx: &mut ViewContext<Pane>) -> impl IntoElement {
|
||||||
let focus_handle = self.focus_handle.clone();
|
let focus_handle = self.focus_handle.clone();
|
||||||
let navigate_backward = IconButton::new("navigate_backward", IconName::ArrowLeft)
|
let navigate_backward = IconButton::new("navigate_backward", IconName::ArrowLeft)
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
|
@ -2592,12 +2592,7 @@ impl Pane {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_tab_drop(
|
fn handle_tab_drop(&mut self, dragged_tab: &DraggedTab, ix: usize, cx: &mut ViewContext<Self>) {
|
||||||
&mut self,
|
|
||||||
dragged_tab: &DraggedTab,
|
|
||||||
ix: usize,
|
|
||||||
cx: &mut ViewContext<'_, Self>,
|
|
||||||
) {
|
|
||||||
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
|
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
|
||||||
if let ControlFlow::Break(()) = custom_drop_handle(self, dragged_tab, cx) {
|
if let ControlFlow::Break(()) = custom_drop_handle(self, dragged_tab, cx) {
|
||||||
return;
|
return;
|
||||||
|
@ -2663,7 +2658,7 @@ impl Pane {
|
||||||
&mut self,
|
&mut self,
|
||||||
dragged_selection: &DraggedSelection,
|
dragged_selection: &DraggedSelection,
|
||||||
dragged_onto: Option<usize>,
|
dragged_onto: Option<usize>,
|
||||||
cx: &mut ViewContext<'_, Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
|
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
|
||||||
if let ControlFlow::Break(()) = custom_drop_handle(self, dragged_selection, cx) {
|
if let ControlFlow::Break(()) = custom_drop_handle(self, dragged_selection, cx) {
|
||||||
|
@ -2681,7 +2676,7 @@ impl Pane {
|
||||||
&mut self,
|
&mut self,
|
||||||
project_entry_id: &ProjectEntryId,
|
project_entry_id: &ProjectEntryId,
|
||||||
target: Option<usize>,
|
target: Option<usize>,
|
||||||
cx: &mut ViewContext<'_, Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
|
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
|
||||||
if let ControlFlow::Break(()) = custom_drop_handle(self, project_entry_id, cx) {
|
if let ControlFlow::Break(()) = custom_drop_handle(self, project_entry_id, cx) {
|
||||||
|
@ -2746,11 +2741,7 @@ impl Pane {
|
||||||
.log_err();
|
.log_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_external_paths_drop(
|
fn handle_external_paths_drop(&mut self, paths: &ExternalPaths, cx: &mut ViewContext<Self>) {
|
||||||
&mut self,
|
|
||||||
paths: &ExternalPaths,
|
|
||||||
cx: &mut ViewContext<'_, Self>,
|
|
||||||
) {
|
|
||||||
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
|
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
|
||||||
if let ControlFlow::Break(()) = custom_drop_handle(self, paths, cx) {
|
if let ControlFlow::Break(()) = custom_drop_handle(self, paths, cx) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub fn schedule_task(
|
||||||
task_to_resolve: &TaskTemplate,
|
task_to_resolve: &TaskTemplate,
|
||||||
task_cx: &TaskContext,
|
task_cx: &TaskContext,
|
||||||
omit_history: bool,
|
omit_history: bool,
|
||||||
cx: &mut ViewContext<'_, Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) {
|
) {
|
||||||
match workspace.project.read(cx).ssh_connection_state(cx) {
|
match workspace.project.read(cx).ssh_connection_state(cx) {
|
||||||
None | Some(ConnectionState::Connected) => {}
|
None | Some(ConnectionState::Connected) => {}
|
||||||
|
@ -44,7 +44,7 @@ pub fn schedule_resolved_task(
|
||||||
task_source_kind: TaskSourceKind,
|
task_source_kind: TaskSourceKind,
|
||||||
mut resolved_task: ResolvedTask,
|
mut resolved_task: ResolvedTask,
|
||||||
omit_history: bool,
|
omit_history: bool,
|
||||||
cx: &mut ViewContext<'_, Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) {
|
) {
|
||||||
if let Some(spawn_in_terminal) = resolved_task.resolved.take() {
|
if let Some(spawn_in_terminal) = resolved_task.resolved.take() {
|
||||||
if !omit_history {
|
if !omit_history {
|
||||||
|
|
|
@ -1706,11 +1706,11 @@ impl Workspace {
|
||||||
cx.defer(|cx| {
|
cx.defer(|cx| {
|
||||||
cx.windows().iter().find(|window| {
|
cx.windows().iter().find(|window| {
|
||||||
window
|
window
|
||||||
.update(cx, |_, window| {
|
.update(cx, |_, cx| {
|
||||||
if window.is_window_active() {
|
if cx.is_window_active() {
|
||||||
//This can only get called when the window's project connection has been lost
|
//This can only get called when the window's project connection has been lost
|
||||||
//so we don't need to prompt the user for anything and instead just close the window
|
//so we don't need to prompt the user for anything and instead just close the window
|
||||||
window.remove_window();
|
cx.remove_window();
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -4561,7 +4561,7 @@ impl Workspace {
|
||||||
div
|
div
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_active_modal(&self, cx: &WindowContext<'_>) -> bool {
|
pub fn has_active_modal(&self, cx: &WindowContext) -> bool {
|
||||||
self.modal_layer.read(cx).has_active_modal()
|
self.modal_layer.read(cx).has_active_modal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5018,7 +5018,7 @@ impl Render for Workspace {
|
||||||
fn resize_bottom_dock(
|
fn resize_bottom_dock(
|
||||||
new_size: Pixels,
|
new_size: Pixels,
|
||||||
workspace: &mut Workspace,
|
workspace: &mut Workspace,
|
||||||
cx: &mut ViewContext<'_, Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) {
|
) {
|
||||||
let size = new_size.min(workspace.bounds.bottom() - RESIZE_HANDLE_SIZE);
|
let size = new_size.min(workspace.bounds.bottom() - RESIZE_HANDLE_SIZE);
|
||||||
workspace.bottom_dock.update(cx, |bottom_dock, cx| {
|
workspace.bottom_dock.update(cx, |bottom_dock, cx| {
|
||||||
|
@ -5026,22 +5026,14 @@ fn resize_bottom_dock(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resize_right_dock(
|
fn resize_right_dock(new_size: Pixels, workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) {
|
||||||
new_size: Pixels,
|
|
||||||
workspace: &mut Workspace,
|
|
||||||
cx: &mut ViewContext<'_, Workspace>,
|
|
||||||
) {
|
|
||||||
let size = new_size.max(workspace.bounds.left() - RESIZE_HANDLE_SIZE);
|
let size = new_size.max(workspace.bounds.left() - RESIZE_HANDLE_SIZE);
|
||||||
workspace.right_dock.update(cx, |right_dock, cx| {
|
workspace.right_dock.update(cx, |right_dock, cx| {
|
||||||
right_dock.resize_active_panel(Some(size), cx);
|
right_dock.resize_active_panel(Some(size), cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resize_left_dock(
|
fn resize_left_dock(new_size: Pixels, workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) {
|
||||||
new_size: Pixels,
|
|
||||||
workspace: &mut Workspace,
|
|
||||||
cx: &mut ViewContext<'_, Workspace>,
|
|
||||||
) {
|
|
||||||
let size = new_size.min(workspace.bounds.right() - RESIZE_HANDLE_SIZE);
|
let size = new_size.min(workspace.bounds.right() - RESIZE_HANDLE_SIZE);
|
||||||
|
|
||||||
workspace.left_dock.update(cx, |left_dock, cx| {
|
workspace.left_dock.update(cx, |left_dock, cx| {
|
||||||
|
@ -6149,7 +6141,7 @@ fn resize_edge(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn join_pane_into_active(active_pane: &View<Pane>, pane: &View<Pane>, cx: &mut WindowContext<'_>) {
|
fn join_pane_into_active(active_pane: &View<Pane>, pane: &View<Pane>, cx: &mut WindowContext) {
|
||||||
if pane == active_pane {
|
if pane == active_pane {
|
||||||
return;
|
return;
|
||||||
} else if pane.read(cx).items_len() == 0 {
|
} else if pane.read(cx).items_len() == 0 {
|
||||||
|
@ -6163,7 +6155,7 @@ fn join_pane_into_active(active_pane: &View<Pane>, pane: &View<Pane>, cx: &mut W
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_all_items(from_pane: &View<Pane>, to_pane: &View<Pane>, cx: &mut WindowContext<'_>) {
|
fn move_all_items(from_pane: &View<Pane>, to_pane: &View<Pane>, cx: &mut WindowContext) {
|
||||||
let destination_is_different = from_pane != to_pane;
|
let destination_is_different = from_pane != to_pane;
|
||||||
let mut moved_items = 0;
|
let mut moved_items = 0;
|
||||||
for (item_ix, item_handle) in from_pane
|
for (item_ix, item_handle) in from_pane
|
||||||
|
@ -6195,7 +6187,7 @@ pub fn move_item(
|
||||||
destination: &View<Pane>,
|
destination: &View<Pane>,
|
||||||
item_id_to_move: EntityId,
|
item_id_to_move: EntityId,
|
||||||
destination_index: usize,
|
destination_index: usize,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) {
|
) {
|
||||||
let Some((item_ix, item_handle)) = source
|
let Some((item_ix, item_handle)) = source
|
||||||
.read(cx)
|
.read(cx)
|
||||||
|
@ -6227,7 +6219,7 @@ pub fn move_active_item(
|
||||||
destination: &View<Pane>,
|
destination: &View<Pane>,
|
||||||
focus_destination: bool,
|
focus_destination: bool,
|
||||||
close_if_empty: bool,
|
close_if_empty: bool,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext,
|
||||||
) {
|
) {
|
||||||
if source == destination {
|
if source == destination {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue