Fix warnings
This commit is contained in:
parent
b893ac2a02
commit
2c3c238c9d
1 changed files with 119 additions and 127 deletions
|
@ -9,8 +9,8 @@ use file_associations::FileAssociations;
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, div, px, rems, svg, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext,
|
actions, div, px, rems, svg, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext,
|
||||||
ClipboardItem, Component, Div, Entity, EventEmitter, FocusHandle, FocusableKeyDispatch, Model,
|
ClipboardItem, Component, Div, EventEmitter, FocusHandle, FocusableKeyDispatch, Model,
|
||||||
ParentElement as _, Pixels, Point, PromptLevel, Render, StatefulInteractive,
|
MouseButton, ParentElement as _, Pixels, Point, PromptLevel, Render, StatefulInteractive,
|
||||||
StatefulInteractivity, StatelessInteractive, Styled, Task, UniformListScrollHandle, View,
|
StatefulInteractivity, StatelessInteractive, Styled, Task, UniformListScrollHandle, View,
|
||||||
ViewContext, VisualContext as _, WeakView, WindowContext,
|
ViewContext, VisualContext as _, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
|
@ -54,8 +54,8 @@ pub struct ProjectPanel {
|
||||||
edit_state: Option<EditState>,
|
edit_state: Option<EditState>,
|
||||||
filename_editor: View<Editor>,
|
filename_editor: View<Editor>,
|
||||||
clipboard_entry: Option<ClipboardEntry>,
|
clipboard_entry: Option<ClipboardEntry>,
|
||||||
dragged_entry_destination: Option<Arc<Path>>,
|
_dragged_entry_destination: Option<Arc<Path>>,
|
||||||
workspace: WeakView<Workspace>,
|
_workspace: WeakView<Workspace>,
|
||||||
has_focus: bool,
|
has_focus: bool,
|
||||||
width: Option<f32>,
|
width: Option<f32>,
|
||||||
pending_serialization: Task<Option<()>>,
|
pending_serialization: Task<Option<()>>,
|
||||||
|
@ -219,7 +219,6 @@ impl ProjectPanel {
|
||||||
// })
|
// })
|
||||||
// .detach();
|
// .detach();
|
||||||
|
|
||||||
let view_id = cx.view().entity_id();
|
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
project: project.clone(),
|
project: project.clone(),
|
||||||
fs: workspace.app_state().fs.clone(),
|
fs: workspace.app_state().fs.clone(),
|
||||||
|
@ -233,8 +232,8 @@ impl ProjectPanel {
|
||||||
filename_editor,
|
filename_editor,
|
||||||
clipboard_entry: None,
|
clipboard_entry: None,
|
||||||
// context_menu: cx.add_view(|cx| ContextMenu::new(view_id, cx)),
|
// context_menu: cx.add_view(|cx| ContextMenu::new(view_id, cx)),
|
||||||
dragged_entry_destination: None,
|
_dragged_entry_destination: None,
|
||||||
workspace: workspace.weak_handle(),
|
_workspace: workspace.weak_handle(),
|
||||||
has_focus: false,
|
has_focus: false,
|
||||||
width: None,
|
width: None,
|
||||||
pending_serialization: Task::ready(None),
|
pending_serialization: Task::ready(None),
|
||||||
|
@ -286,8 +285,8 @@ impl ProjectPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&Event::SplitEntry { entry_id } => {
|
&Event::SplitEntry { entry_id } => {
|
||||||
// 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) {
|
||||||
// if let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
|
if let Some(_entry) = worktree.read(cx).entry_for_id(entry_id) {
|
||||||
// workspace
|
// workspace
|
||||||
// .split_path(
|
// .split_path(
|
||||||
// ProjectPath {
|
// ProjectPath {
|
||||||
|
@ -297,8 +296,8 @@ impl ProjectPanel {
|
||||||
// cx,
|
// cx,
|
||||||
// )
|
// )
|
||||||
// .detach_and_log_err(cx);
|
// .detach_and_log_err(cx);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
@ -366,10 +365,11 @@ impl ProjectPanel {
|
||||||
|
|
||||||
fn deploy_context_menu(
|
fn deploy_context_menu(
|
||||||
&mut self,
|
&mut self,
|
||||||
position: Point<Pixels>,
|
_position: Point<Pixels>,
|
||||||
entry_id: ProjectEntryId,
|
_entry_id: ProjectEntryId,
|
||||||
cx: &mut ViewContext<Self>,
|
_cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
|
todo!()
|
||||||
// let project = self.project.read(cx);
|
// let project = self.project.read(cx);
|
||||||
|
|
||||||
// let worktree_id = if let Some(id) = project.worktree_id_for_entry(entry_id, cx) {
|
// let worktree_id = if let Some(id) = project.worktree_id_for_entry(entry_id, cx) {
|
||||||
|
@ -955,7 +955,7 @@ impl ProjectPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_in_terminal(&mut self, _: &OpenInTerminal, cx: &mut ViewContext<Self>) {
|
fn open_in_terminal(&mut self, _: &OpenInTerminal, _cx: &mut ViewContext<Self>) {
|
||||||
todo!()
|
todo!()
|
||||||
// if let Some((worktree, entry)) = self.selected_entry(cx) {
|
// if let Some((worktree, entry)) = self.selected_entry(cx) {
|
||||||
// let window = cx.window();
|
// let window = cx.window();
|
||||||
|
@ -990,36 +990,37 @@ impl ProjectPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_entry(
|
// todo!()
|
||||||
&mut self,
|
// fn move_entry(
|
||||||
entry_to_move: ProjectEntryId,
|
// &mut self,
|
||||||
destination: ProjectEntryId,
|
// entry_to_move: ProjectEntryId,
|
||||||
destination_is_file: bool,
|
// destination: ProjectEntryId,
|
||||||
cx: &mut ViewContext<Self>,
|
// destination_is_file: bool,
|
||||||
) {
|
// cx: &mut ViewContext<Self>,
|
||||||
let destination_worktree = self.project.update(cx, |project, cx| {
|
// ) {
|
||||||
let entry_path = project.path_for_entry(entry_to_move, cx)?;
|
// let destination_worktree = self.project.update(cx, |project, cx| {
|
||||||
let destination_entry_path = project.path_for_entry(destination, cx)?.path.clone();
|
// let entry_path = project.path_for_entry(entry_to_move, cx)?;
|
||||||
|
// let destination_entry_path = project.path_for_entry(destination, cx)?.path.clone();
|
||||||
|
|
||||||
let mut destination_path = destination_entry_path.as_ref();
|
// let mut destination_path = destination_entry_path.as_ref();
|
||||||
if destination_is_file {
|
// if destination_is_file {
|
||||||
destination_path = destination_path.parent()?;
|
// destination_path = destination_path.parent()?;
|
||||||
}
|
// }
|
||||||
|
|
||||||
let mut new_path = destination_path.to_path_buf();
|
// let mut new_path = destination_path.to_path_buf();
|
||||||
new_path.push(entry_path.path.file_name()?);
|
// new_path.push(entry_path.path.file_name()?);
|
||||||
if new_path != entry_path.path.as_ref() {
|
// if new_path != entry_path.path.as_ref() {
|
||||||
let task = project.rename_entry(entry_to_move, new_path, cx)?;
|
// let task = project.rename_entry(entry_to_move, new_path, cx)?;
|
||||||
cx.foreground_executor().spawn(task).detach_and_log_err(cx);
|
// cx.foreground_executor().spawn(task).detach_and_log_err(cx);
|
||||||
}
|
// }
|
||||||
|
|
||||||
Some(project.worktree_id_for_entry(destination, cx)?)
|
// Some(project.worktree_id_for_entry(destination, cx)?)
|
||||||
});
|
// });
|
||||||
|
|
||||||
if let Some(destination_worktree) = destination_worktree {
|
// if let Some(destination_worktree) = destination_worktree {
|
||||||
self.expand_entry(destination_worktree, destination, cx);
|
// self.expand_entry(destination_worktree, destination, cx);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn index_for_selection(&self, selection: Selection) -> Option<(usize, usize, usize)> {
|
fn index_for_selection(&self, selection: Selection) -> Option<(usize, usize, usize)> {
|
||||||
let mut entry_index = 0;
|
let mut entry_index = 0;
|
||||||
|
@ -1367,7 +1368,9 @@ impl ProjectPanel {
|
||||||
if let (Some(editor), true) = (editor, show_editor) {
|
if let (Some(editor), true) = (editor, show_editor) {
|
||||||
div().w_full().child(editor.clone())
|
div().w_full().child(editor.clone())
|
||||||
} else {
|
} else {
|
||||||
div().child(Label::new(details.filename.clone()))
|
div()
|
||||||
|
.text_color(filename_text_color)
|
||||||
|
.child(Label::new(details.filename.clone()))
|
||||||
}
|
}
|
||||||
.ml_1(),
|
.ml_1(),
|
||||||
)
|
)
|
||||||
|
@ -1411,21 +1414,16 @@ impl ProjectPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// .on_down(MouseButton::Right, move |event, this, cx| {
|
.on_mouse_down(MouseButton::Right, move |this, event, cx| {
|
||||||
// this.deploy_context_menu(event.position, entry_id, cx);
|
this.deploy_context_menu(event.position, entry_id, cx);
|
||||||
// })
|
})
|
||||||
// .on_up(MouseButton::Left, move |_, this, cx| {
|
// .on_drop::<ProjectEntryId>(|this, event, cx| {
|
||||||
// if let Some((_, dragged_entry)) = cx
|
|
||||||
// .global::<DragAndDrop<Workspace>>()
|
|
||||||
// .currently_dragged::<ProjectEntryId>(cx.window())
|
|
||||||
// {
|
|
||||||
// this.move_entry(
|
// this.move_entry(
|
||||||
// *dragged_entry,
|
// *dragged_entry,
|
||||||
// entry_id,
|
// entry_id,
|
||||||
// matches!(details.kind, EntryKind::File(_)),
|
// matches!(details.kind, EntryKind::File(_)),
|
||||||
// cx,
|
// cx,
|
||||||
// );
|
// );
|
||||||
// }
|
|
||||||
// })
|
// })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1433,10 +1431,7 @@ impl ProjectPanel {
|
||||||
impl Render for ProjectPanel {
|
impl Render for ProjectPanel {
|
||||||
type Element = Div<Self, StatefulInteractivity<Self>, FocusableKeyDispatch<Self>>;
|
type Element = Div<Self, StatefulInteractivity<Self>, FocusableKeyDispatch<Self>>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
||||||
let theme = cx.theme();
|
|
||||||
let last_worktree_root_id = self.last_worktree_root_id;
|
|
||||||
|
|
||||||
let has_worktree = self.visible_entries.len() != 0;
|
let has_worktree = self.visible_entries.len() != 0;
|
||||||
|
|
||||||
if has_worktree {
|
if has_worktree {
|
||||||
|
@ -1475,10 +1470,7 @@ impl Render for ProjectPanel {
|
||||||
|this: &mut Self, range, cx| {
|
|this: &mut Self, range, cx| {
|
||||||
let mut items = SmallVec::new();
|
let mut items = SmallVec::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(
|
items.push(this.render_entry(id, details, cx));
|
||||||
id, details, // &mut dragged_entry_destination,
|
|
||||||
cx,
|
|
||||||
));
|
|
||||||
});
|
});
|
||||||
items
|
items
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue