Not working yet file-finder2 (#3321)
Porting file_finder Release Notes: - N/A
This commit is contained in:
commit
df64a3c701
18 changed files with 2193 additions and 98 deletions
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -3061,6 +3061,31 @@ dependencies = [
|
||||||
"workspace",
|
"workspace",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "file_finder2"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"collections",
|
||||||
|
"ctor",
|
||||||
|
"editor2",
|
||||||
|
"env_logger 0.9.3",
|
||||||
|
"fuzzy2",
|
||||||
|
"gpui2",
|
||||||
|
"language2",
|
||||||
|
"menu2",
|
||||||
|
"picker2",
|
||||||
|
"postage",
|
||||||
|
"project2",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"settings2",
|
||||||
|
"text2",
|
||||||
|
"theme2",
|
||||||
|
"ui2",
|
||||||
|
"util",
|
||||||
|
"workspace2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filetime"
|
name = "filetime"
|
||||||
version = "0.2.22"
|
version = "0.2.22"
|
||||||
|
@ -11424,6 +11449,7 @@ dependencies = [
|
||||||
"editor2",
|
"editor2",
|
||||||
"env_logger 0.9.3",
|
"env_logger 0.9.3",
|
||||||
"feature_flags2",
|
"feature_flags2",
|
||||||
|
"file_finder2",
|
||||||
"fs2",
|
"fs2",
|
||||||
"fsevent",
|
"fsevent",
|
||||||
"futures 0.3.28",
|
"futures 0.3.28",
|
||||||
|
|
|
@ -9383,8 +9383,8 @@ impl Render for Editor {
|
||||||
EditorMode::SingleLine => {
|
EditorMode::SingleLine => {
|
||||||
TextStyle {
|
TextStyle {
|
||||||
color: cx.theme().colors().text,
|
color: cx.theme().colors().text,
|
||||||
font_family: "Zed Sans".into(), // todo!()
|
font_family: settings.ui_font.family.clone(), // todo!()
|
||||||
font_features: FontFeatures::default(),
|
font_features: settings.ui_font.features,
|
||||||
font_size: rems(0.875).into(),
|
font_size: rems(0.875).into(),
|
||||||
font_weight: FontWeight::NORMAL,
|
font_weight: FontWeight::NORMAL,
|
||||||
font_style: FontStyle::Normal,
|
font_style: FontStyle::Normal,
|
||||||
|
|
|
@ -1448,6 +1448,7 @@ impl EditorElement {
|
||||||
|
|
||||||
let snapshot = editor.snapshot(cx);
|
let snapshot = editor.snapshot(cx);
|
||||||
let style = self.style.clone();
|
let style = self.style.clone();
|
||||||
|
|
||||||
let font_id = cx.text_system().font_id(&style.text.font()).unwrap();
|
let font_id = cx.text_system().font_id(&style.text.font()).unwrap();
|
||||||
let font_size = style.text.font_size.to_pixels(cx.rem_size());
|
let font_size = style.text.font_size.to_pixels(cx.rem_size());
|
||||||
let line_height = style.text.line_height_in_pixels(cx.rem_size());
|
let line_height = style.text.line_height_in_pixels(cx.rem_size());
|
||||||
|
|
37
crates/file_finder2/Cargo.toml
Normal file
37
crates/file_finder2/Cargo.toml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
[package]
|
||||||
|
name = "file_finder2"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/file_finder.rs"
|
||||||
|
doctest = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
editor = { package = "editor2", path = "../editor2" }
|
||||||
|
collections = { path = "../collections" }
|
||||||
|
fuzzy = { package = "fuzzy2", path = "../fuzzy2" }
|
||||||
|
gpui = { package = "gpui2", path = "../gpui2" }
|
||||||
|
menu = { package = "menu2", path = "../menu2" }
|
||||||
|
picker = { package = "picker2", path = "../picker2" }
|
||||||
|
project = { package = "project2", path = "../project2" }
|
||||||
|
settings = { package = "settings2", path = "../settings2" }
|
||||||
|
text = { package = "text2", path = "../text2" }
|
||||||
|
util = { path = "../util" }
|
||||||
|
theme = { package = "theme2", path = "../theme2" }
|
||||||
|
ui = { package = "ui2", path = "../ui2" }
|
||||||
|
workspace = { package = "workspace2", path = "../workspace2" }
|
||||||
|
postage.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
editor = { package = "editor2", path = "../editor2", features = ["test-support"] }
|
||||||
|
gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
|
||||||
|
language = { package = "language2", path = "../language2", features = ["test-support"] }
|
||||||
|
workspace = { package = "workspace2", path = "../workspace2", features = ["test-support"] }
|
||||||
|
theme = { package = "theme2", path = "../theme2", features = ["test-support"] }
|
||||||
|
|
||||||
|
serde_json.workspace = true
|
||||||
|
ctor.workspace = true
|
||||||
|
env_logger.workspace = true
|
1976
crates/file_finder2/src/file_finder.rs
Normal file
1976
crates/file_finder2/src/file_finder.rs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,8 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
div, AnyView, AnyWindowHandle, AppCell, AppContext, AsyncAppContext, BackgroundExecutor,
|
div, Action, AnyView, AnyWindowHandle, AppCell, AppContext, AsyncAppContext,
|
||||||
Context, Div, EventEmitter, ForegroundExecutor, InputEvent, KeyDownEvent, Keystroke, Model,
|
BackgroundExecutor, Context, Div, EventEmitter, ForegroundExecutor, InputEvent, KeyDownEvent,
|
||||||
ModelContext, Render, Result, Task, TestDispatcher, TestPlatform, View, ViewContext,
|
Keystroke, Model, ModelContext, Render, Result, Task, TestDispatcher, TestPlatform, View,
|
||||||
VisualContext, WindowContext, WindowHandle, WindowOptions,
|
ViewContext, VisualContext, WindowContext, WindowHandle, WindowOptions,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, bail};
|
use anyhow::{anyhow, bail};
|
||||||
use futures::{Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
|
@ -81,6 +81,7 @@ impl TestAppContext {
|
||||||
let platform = TestPlatform::new(background_executor.clone(), foreground_executor.clone());
|
let platform = TestPlatform::new(background_executor.clone(), foreground_executor.clone());
|
||||||
let asset_source = Arc::new(());
|
let asset_source = Arc::new(());
|
||||||
let http_client = util::http::FakeHttpClient::with_404_response();
|
let http_client = util::http::FakeHttpClient::with_404_response();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
app: AppContext::new(platform.clone(), asset_source, http_client),
|
app: AppContext::new(platform.clone(), asset_source, http_client),
|
||||||
background_executor,
|
background_executor,
|
||||||
|
@ -213,6 +214,15 @@ impl TestAppContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn dispatch_action<A>(&mut self, window: AnyWindowHandle, action: A)
|
||||||
|
where
|
||||||
|
A: Action,
|
||||||
|
{
|
||||||
|
window
|
||||||
|
.update(self, |_, cx| cx.dispatch_action(action.boxed_clone()))
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn dispatch_keystroke(
|
pub fn dispatch_keystroke(
|
||||||
&mut self,
|
&mut self,
|
||||||
window: AnyWindowHandle,
|
window: AnyWindowHandle,
|
||||||
|
@ -390,6 +400,13 @@ impl<'a> VisualTestContext<'a> {
|
||||||
pub fn from_window(window: AnyWindowHandle, cx: &'a mut TestAppContext) -> Self {
|
pub fn from_window(window: AnyWindowHandle, cx: &'a mut TestAppContext) -> Self {
|
||||||
Self { cx, window }
|
Self { cx, window }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn dispatch_action<A>(&mut self, action: A)
|
||||||
|
where
|
||||||
|
A: Action,
|
||||||
|
{
|
||||||
|
self.cx.dispatch_action(self.window, action)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Context for VisualTestContext<'a> {
|
impl<'a> Context for VisualTestContext<'a> {
|
||||||
|
|
|
@ -15,7 +15,7 @@ use taffy::style::Overflow;
|
||||||
pub fn uniform_list<Id, V, C>(
|
pub fn uniform_list<Id, V, C>(
|
||||||
id: Id,
|
id: Id,
|
||||||
item_count: usize,
|
item_count: usize,
|
||||||
f: impl 'static + Fn(&mut V, Range<usize>, &mut ViewContext<V>) -> SmallVec<[C; 64]>,
|
f: impl 'static + Fn(&mut V, Range<usize>, &mut ViewContext<V>) -> Vec<C>,
|
||||||
) -> UniformList<V>
|
) -> UniformList<V>
|
||||||
where
|
where
|
||||||
Id: Into<ElementId>,
|
Id: Into<ElementId>,
|
||||||
|
|
|
@ -422,8 +422,11 @@ impl<'a> WindowContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dispatch_action(&mut self, action: Box<dyn Action>) {
|
pub fn dispatch_action(&mut self, action: Box<dyn Action>) {
|
||||||
|
dbg!("BEFORE FOCUS");
|
||||||
if let Some(focus_handle) = self.focused() {
|
if let Some(focus_handle) = self.focused() {
|
||||||
|
dbg!("BEFORE DEFER", focus_handle.id);
|
||||||
self.defer(move |cx| {
|
self.defer(move |cx| {
|
||||||
|
dbg!("AFTER DEFER");
|
||||||
if let Some(node_id) = cx
|
if let Some(node_id) = cx
|
||||||
.window
|
.window
|
||||||
.current_frame
|
.current_frame
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl<D: PickerDelegate> Picker<D> {
|
||||||
self.editor.update(cx, |editor, cx| editor.focus(cx));
|
self.editor.update(cx, |editor, cx| editor.focus(cx));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_next(&mut self, _: &menu::SelectNext, cx: &mut ViewContext<Self>) {
|
pub fn select_next(&mut self, _: &menu::SelectNext, cx: &mut ViewContext<Self>) {
|
||||||
let count = self.delegate.match_count();
|
let count = self.delegate.match_count();
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
let index = self.delegate.selected_index();
|
let index = self.delegate.selected_index();
|
||||||
|
@ -98,6 +98,15 @@ impl<D: PickerDelegate> Picker<D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cycle_selection(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
let count = self.delegate.match_count();
|
||||||
|
let index = self.delegate.selected_index();
|
||||||
|
let new_index = if index + 1 == count { 0 } else { index + 1 };
|
||||||
|
self.delegate.set_selected_index(new_index, cx);
|
||||||
|
self.scroll_handle.scroll_to_item(new_index);
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
fn cancel(&mut self, _: &menu::Cancel, cx: &mut ViewContext<Self>) {
|
fn cancel(&mut self, _: &menu::Cancel, cx: &mut ViewContext<Self>) {
|
||||||
self.delegate.dismissed(cx);
|
self.delegate.dismissed(cx);
|
||||||
}
|
}
|
||||||
|
@ -137,6 +146,11 @@ impl<D: PickerDelegate> Picker<D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn refresh(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
let query = self.editor.read(cx).text(cx);
|
||||||
|
self.update_matches(query, cx);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update_matches(&mut self, query: String, cx: &mut ViewContext<Self>) {
|
pub fn update_matches(&mut self, query: String, cx: &mut ViewContext<Self>) {
|
||||||
let update = self.delegate.update_matches(query, cx);
|
let update = self.delegate.update_matches(query, cx);
|
||||||
self.matches_updated(cx);
|
self.matches_updated(cx);
|
||||||
|
|
|
@ -21,7 +21,6 @@ use project::{
|
||||||
};
|
};
|
||||||
use project_panel_settings::{ProjectPanelDockPosition, ProjectPanelSettings};
|
use project_panel_settings::{ProjectPanelDockPosition, ProjectPanelSettings};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use smallvec::SmallVec;
|
|
||||||
use std::{
|
use std::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
collections::{hash_map, HashMap},
|
collections::{hash_map, HashMap},
|
||||||
|
@ -1458,7 +1457,7 @@ impl Render for ProjectPanel {
|
||||||
.map(|(_, worktree_entries)| worktree_entries.len())
|
.map(|(_, worktree_entries)| worktree_entries.len())
|
||||||
.sum(),
|
.sum(),
|
||||||
|this: &mut Self, range, cx| {
|
|this: &mut Self, range, cx| {
|
||||||
let mut items = SmallVec::new();
|
let mut items = Vec::new();
|
||||||
this.for_each_visible_entry(range, cx, |id, details, cx| {
|
this.for_each_visible_entry(range, cx, |id, details, cx| {
|
||||||
items.push(this.render_entry(id, details, cx));
|
items.push(this.render_entry(id, details, cx));
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,6 +35,7 @@ pub(crate) fn one_dark() -> Theme {
|
||||||
id: "one_dark".to_string(),
|
id: "one_dark".to_string(),
|
||||||
name: "One Dark".into(),
|
name: "One Dark".into(),
|
||||||
appearance: Appearance::Dark,
|
appearance: Appearance::Dark,
|
||||||
|
|
||||||
styles: ThemeStyles {
|
styles: ThemeStyles {
|
||||||
system: SystemColors::default(),
|
system: SystemColors::default(),
|
||||||
colors: ThemeColors {
|
colors: ThemeColors {
|
||||||
|
|
|
@ -19,6 +19,7 @@ const MIN_LINE_HEIGHT: f32 = 1.0;
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ThemeSettings {
|
pub struct ThemeSettings {
|
||||||
pub ui_font_size: Pixels,
|
pub ui_font_size: Pixels,
|
||||||
|
pub ui_font: Font,
|
||||||
pub buffer_font: Font,
|
pub buffer_font: Font,
|
||||||
pub buffer_font_size: Pixels,
|
pub buffer_font_size: Pixels,
|
||||||
pub buffer_line_height: BufferLineHeight,
|
pub buffer_line_height: BufferLineHeight,
|
||||||
|
@ -120,6 +121,12 @@ impl settings::Settings for ThemeSettings {
|
||||||
|
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
ui_font_size: defaults.ui_font_size.unwrap_or(16.).into(),
|
ui_font_size: defaults.ui_font_size.unwrap_or(16.).into(),
|
||||||
|
ui_font: Font {
|
||||||
|
family: "Helvetica".into(),
|
||||||
|
features: Default::default(),
|
||||||
|
weight: Default::default(),
|
||||||
|
style: Default::default(),
|
||||||
|
},
|
||||||
buffer_font: Font {
|
buffer_font: Font {
|
||||||
family: defaults.buffer_font_family.clone().unwrap().into(),
|
family: defaults.buffer_font_family.clone().unwrap().into(),
|
||||||
features: defaults.buffer_font_features.clone().unwrap(),
|
features: defaults.buffer_font_features.clone().unwrap(),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use gpui::{Div, Render};
|
use gpui::{Div, Render};
|
||||||
use theme2::ActiveTheme;
|
use settings2::Settings;
|
||||||
|
use theme2::{ActiveTheme, ThemeSettings};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{h_stack, v_stack, KeyBinding, Label, LabelSize, StyledExt, TextColor};
|
use crate::{h_stack, v_stack, KeyBinding, Label, LabelSize, StyledExt, TextColor};
|
||||||
|
@ -34,9 +35,10 @@ impl Render for TextTooltip {
|
||||||
type Element = Div<Self>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone();
|
||||||
v_stack()
|
v_stack()
|
||||||
.elevation_2(cx)
|
.elevation_2(cx)
|
||||||
.font("Zed Sans")
|
.font(ui_font)
|
||||||
.text_ui_sm()
|
.text_ui_sm()
|
||||||
.text_color(cx.theme().colors().text)
|
.text_color(cx.theme().colors().text)
|
||||||
.py_1()
|
.py_1()
|
||||||
|
|
|
@ -206,13 +206,14 @@ impl Render for Workspace {
|
||||||
.child(self.editor_1.clone())],
|
.child(self.editor_1.clone())],
|
||||||
SplitDirection::Horizontal,
|
SplitDirection::Horizontal,
|
||||||
);
|
);
|
||||||
|
let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone();
|
||||||
|
|
||||||
div()
|
div()
|
||||||
.relative()
|
.relative()
|
||||||
.size_full()
|
.size_full()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.font("Zed Sans")
|
.font(ui_font)
|
||||||
.gap_0()
|
.gap_0()
|
||||||
.justify_start()
|
.justify_start()
|
||||||
.items_start()
|
.items_start()
|
||||||
|
|
|
@ -71,6 +71,14 @@ impl ModalLayer {
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn current_modal<V>(&self) -> Option<View<V>>
|
||||||
|
where
|
||||||
|
V: 'static,
|
||||||
|
{
|
||||||
|
let active_modal = self.active_modal.as_ref()?;
|
||||||
|
active_modal.modal.clone().downcast::<V>().ok()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ModalLayer {
|
impl Render for ModalLayer {
|
||||||
|
|
|
@ -67,7 +67,7 @@ use std::{
|
||||||
sync::{atomic::AtomicUsize, Arc},
|
sync::{atomic::AtomicUsize, Arc},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use theme2::ActiveTheme;
|
use theme2::{ActiveTheme, ThemeSettings};
|
||||||
pub use toolbar::{ToolbarItemLocation, ToolbarItemView};
|
pub use toolbar::{ToolbarItemLocation, ToolbarItemView};
|
||||||
use ui::TextColor;
|
use ui::TextColor;
|
||||||
use ui::{h_stack, Button, ButtonVariant, KeyBinding, Label, TextTooltip};
|
use ui::{h_stack, Button, ButtonVariant, KeyBinding, Label, TextTooltip};
|
||||||
|
@ -1774,50 +1774,50 @@ impl Workspace {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn open_abs_path(
|
pub fn open_abs_path(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// abs_path: PathBuf,
|
abs_path: PathBuf,
|
||||||
// visible: bool,
|
visible: bool,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> Task<anyhow::Result<Box<dyn ItemHandle>>> {
|
) -> Task<anyhow::Result<Box<dyn ItemHandle>>> {
|
||||||
// cx.spawn(|workspace, mut cx| async move {
|
cx.spawn(|workspace, mut cx| async move {
|
||||||
// let open_paths_task_result = workspace
|
let open_paths_task_result = workspace
|
||||||
// .update(&mut cx, |workspace, cx| {
|
.update(&mut cx, |workspace, cx| {
|
||||||
// workspace.open_paths(vec![abs_path.clone()], visible, cx)
|
workspace.open_paths(vec![abs_path.clone()], visible, cx)
|
||||||
// })
|
})
|
||||||
// .with_context(|| format!("open abs path {abs_path:?} task spawn"))?
|
.with_context(|| format!("open abs path {abs_path:?} task spawn"))?
|
||||||
// .await;
|
.await;
|
||||||
// anyhow::ensure!(
|
anyhow::ensure!(
|
||||||
// open_paths_task_result.len() == 1,
|
open_paths_task_result.len() == 1,
|
||||||
// "open abs path {abs_path:?} task returned incorrect number of results"
|
"open abs path {abs_path:?} task returned incorrect number of results"
|
||||||
// );
|
);
|
||||||
// match open_paths_task_result
|
match open_paths_task_result
|
||||||
// .into_iter()
|
.into_iter()
|
||||||
// .next()
|
.next()
|
||||||
// .expect("ensured single task result")
|
.expect("ensured single task result")
|
||||||
// {
|
{
|
||||||
// Some(open_result) => {
|
Some(open_result) => {
|
||||||
// open_result.with_context(|| format!("open abs path {abs_path:?} task join"))
|
open_result.with_context(|| format!("open abs path {abs_path:?} task join"))
|
||||||
// }
|
}
|
||||||
// None => anyhow::bail!("open abs path {abs_path:?} task returned None"),
|
None => anyhow::bail!("open abs path {abs_path:?} task returned None"),
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn split_abs_path(
|
pub fn split_abs_path(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// abs_path: PathBuf,
|
abs_path: PathBuf,
|
||||||
// visible: bool,
|
visible: bool,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> Task<anyhow::Result<Box<dyn ItemHandle>>> {
|
) -> Task<anyhow::Result<Box<dyn ItemHandle>>> {
|
||||||
// let project_path_task =
|
let project_path_task =
|
||||||
// Workspace::project_path_for_path(self.project.clone(), &abs_path, visible, cx);
|
Workspace::project_path_for_path(self.project.clone(), &abs_path, visible, cx);
|
||||||
// cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
// let (_, path) = project_path_task.await?;
|
let (_, path) = project_path_task.await?;
|
||||||
// this.update(&mut cx, |this, cx| this.split_path(path, cx))?
|
this.update(&mut cx, |this, cx| this.split_path(path, cx))?
|
||||||
// .await
|
.await
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub fn open_path(
|
pub fn open_path(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -1844,37 +1844,37 @@ impl Workspace {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn split_path(
|
pub fn split_path(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// path: impl Into<ProjectPath>,
|
path: impl Into<ProjectPath>,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> Task<Result<Box<dyn ItemHandle>, anyhow::Error>> {
|
) -> Task<Result<Box<dyn ItemHandle>, anyhow::Error>> {
|
||||||
// let pane = self.last_active_center_pane.clone().unwrap_or_else(|| {
|
let pane = self.last_active_center_pane.clone().unwrap_or_else(|| {
|
||||||
// self.panes
|
self.panes
|
||||||
// .first()
|
.first()
|
||||||
// .expect("There must be an active pane")
|
.expect("There must be an active pane")
|
||||||
// .downgrade()
|
.downgrade()
|
||||||
// });
|
});
|
||||||
|
|
||||||
// if let Member::Pane(center_pane) = &self.center.root {
|
if let Member::Pane(center_pane) = &self.center.root {
|
||||||
// if center_pane.read(cx).items_len() == 0 {
|
if center_pane.read(cx).items_len() == 0 {
|
||||||
// return self.open_path(path, Some(pane), true, cx);
|
return self.open_path(path, Some(pane), true, cx);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// let task = self.load_path(path.into(), cx);
|
let task = self.load_path(path.into(), cx);
|
||||||
// cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
// let (project_entry_id, build_item) = task.await?;
|
let (project_entry_id, build_item) = task.await?;
|
||||||
// this.update(&mut cx, move |this, cx| -> Option<_> {
|
this.update(&mut cx, move |this, cx| -> Option<_> {
|
||||||
// let pane = pane.upgrade(cx)?;
|
let pane = pane.upgrade()?;
|
||||||
// let new_pane = this.split_pane(pane, SplitDirection::Right, cx);
|
let new_pane = this.split_pane(pane, SplitDirection::Right, cx);
|
||||||
// new_pane.update(cx, |new_pane, cx| {
|
new_pane.update(cx, |new_pane, cx| {
|
||||||
// Some(new_pane.open_item(project_entry_id, true, cx, build_item))
|
Some(new_pane.open_item(project_entry_id, true, cx, build_item))
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
// .map(|option| option.ok_or_else(|| anyhow!("pane was dropped")))?
|
.map(|option| option.ok_or_else(|| anyhow!("pane was dropped")))?
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub(crate) fn load_path(
|
pub(crate) fn load_path(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -3038,10 +3038,10 @@ impl Workspace {
|
||||||
|
|
||||||
fn force_remove_pane(&mut self, pane: &View<Pane>, cx: &mut ViewContext<Workspace>) {
|
fn force_remove_pane(&mut self, pane: &View<Pane>, cx: &mut ViewContext<Workspace>) {
|
||||||
self.panes.retain(|p| p != pane);
|
self.panes.retain(|p| p != pane);
|
||||||
if true {
|
self.panes
|
||||||
todo!()
|
.last()
|
||||||
// cx.focus(self.panes.last().unwrap());
|
.unwrap()
|
||||||
}
|
.update(cx, |pane, cx| pane.focus(cx));
|
||||||
if self.last_active_center_pane == Some(pane.downgrade()) {
|
if self.last_active_center_pane == Some(pane.downgrade()) {
|
||||||
self.last_active_center_pane = None;
|
self.last_active_center_pane = None;
|
||||||
}
|
}
|
||||||
|
@ -3410,10 +3410,6 @@ impl Workspace {
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo!()
|
|
||||||
// #[cfg(any(test, feature = "test-support"))]
|
|
||||||
// pub fn test_new(project: ModelHandle<Project>, cx: &mut ViewContext<Self>) -> Self {
|
|
||||||
// use node_runtime::FakeNodeRuntime;
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub fn test_new(project: Model<Project>, cx: &mut ViewContext<Self>) -> Self {
|
pub fn test_new(project: Model<Project>, cx: &mut ViewContext<Self>) -> Self {
|
||||||
use gpui::Context;
|
use gpui::Context;
|
||||||
|
@ -3433,7 +3429,9 @@ impl Workspace {
|
||||||
initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
|
initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
|
||||||
node_runtime: FakeNodeRuntime::new(),
|
node_runtime: FakeNodeRuntime::new(),
|
||||||
});
|
});
|
||||||
Self::new(0, project, app_state, cx)
|
let workspace = Self::new(0, project, app_state, cx);
|
||||||
|
workspace.active_pane.update(cx, |pane, cx| pane.focus(cx));
|
||||||
|
workspace
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn render_dock(&self, position: DockPosition, cx: &WindowContext) -> Option<AnyElement<Self>> {
|
// fn render_dock(&self, position: DockPosition, cx: &WindowContext) -> Option<AnyElement<Self>> {
|
||||||
|
@ -3489,6 +3487,10 @@ impl Workspace {
|
||||||
div
|
div
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn current_modal<V: Modal + 'static>(&mut self, cx: &ViewContext<Self>) -> Option<View<V>> {
|
||||||
|
self.modal_layer.read(cx).current_modal()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn toggle_modal<V: Modal, B>(&mut self, cx: &mut ViewContext<Self>, build: B)
|
pub fn toggle_modal<V: Modal, B>(&mut self, cx: &mut ViewContext<Self>, build: B)
|
||||||
where
|
where
|
||||||
B: FnOnce(&mut ViewContext<V>) -> V,
|
B: FnOnce(&mut ViewContext<V>) -> V,
|
||||||
|
@ -3712,6 +3714,7 @@ impl Render for Workspace {
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
let mut context = KeyContext::default();
|
let mut context = KeyContext::default();
|
||||||
context.add("Workspace");
|
context.add("Workspace");
|
||||||
|
let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone();
|
||||||
|
|
||||||
self.add_workspace_actions_listeners(div())
|
self.add_workspace_actions_listeners(div())
|
||||||
.context(context)
|
.context(context)
|
||||||
|
@ -3719,7 +3722,7 @@ impl Render for Workspace {
|
||||||
.size_full()
|
.size_full()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.font("Zed Sans")
|
.font(ui_font)
|
||||||
.gap_0()
|
.gap_0()
|
||||||
.justify_start()
|
.justify_start()
|
||||||
.items_start()
|
.items_start()
|
||||||
|
|
|
@ -36,7 +36,7 @@ copilot = { package = "copilot2", path = "../copilot2" }
|
||||||
db = { package = "db2", path = "../db2" }
|
db = { package = "db2", path = "../db2" }
|
||||||
editor = { package="editor2", path = "../editor2" }
|
editor = { package="editor2", path = "../editor2" }
|
||||||
# feedback = { path = "../feedback" }
|
# feedback = { path = "../feedback" }
|
||||||
# file_finder = { path = "../file_finder" }
|
file_finder = { package="file_finder2", path = "../file_finder2" }
|
||||||
# search = { path = "../search" }
|
# search = { path = "../search" }
|
||||||
fs = { package = "fs2", path = "../fs2" }
|
fs = { package = "fs2", path = "../fs2" }
|
||||||
fsevent = { path = "../fsevent" }
|
fsevent = { path = "../fsevent" }
|
||||||
|
|
|
@ -190,7 +190,7 @@ fn main() {
|
||||||
// recent_projects::init(cx);
|
// recent_projects::init(cx);
|
||||||
|
|
||||||
go_to_line::init(cx);
|
go_to_line::init(cx);
|
||||||
// file_finder::init(cx);
|
file_finder::init(cx);
|
||||||
// outline::init(cx);
|
// outline::init(cx);
|
||||||
// project_symbols::init(cx);
|
// project_symbols::init(cx);
|
||||||
project_panel::init(Assets, cx);
|
project_panel::init(Assets, cx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue