Remove optional from EditorTab::new.
This commit is contained in:
parent
dc778dd859
commit
b607a6daaa
@ -43,7 +43,7 @@ impl<'a> App<'a> {
|
|||||||
pub fn new(root_path: PathBuf) -> Result<Self> {
|
pub fn new(root_path: PathBuf) -> Result<Self> {
|
||||||
trace!(target:Self::ID, "Building {}", Self::ID);
|
trace!(target:Self::ID, "Building {}", Self::ID);
|
||||||
let app = Self {
|
let app = Self {
|
||||||
editor_tab: EditorTab::new(None),
|
editor_tab: EditorTab::new(),
|
||||||
explorer: Explorer::new(&root_path)?,
|
explorer: Explorer::new(&root_path)?,
|
||||||
logger: Logger::new(),
|
logger: Logger::new(),
|
||||||
menu_bar: MenuBar::new(),
|
menu_bar: MenuBar::new(),
|
||||||
|
|||||||
@ -21,25 +21,12 @@ pub struct EditorTab {
|
|||||||
impl EditorTab {
|
impl EditorTab {
|
||||||
pub const ID: &str = "EditorTab";
|
pub const ID: &str = "EditorTab";
|
||||||
|
|
||||||
pub fn new(path: Option<&std::path::PathBuf>) -> Self {
|
pub fn new() -> Self {
|
||||||
trace!(target:Self::ID, "Building EditorTab with path {path:?}");
|
trace!(target:Self::ID, "Building {}", Self::ID);
|
||||||
match path {
|
Self {
|
||||||
None => Self {
|
|
||||||
editors: HashMap::new(),
|
editors: HashMap::new(),
|
||||||
tab_order: Vec::new(),
|
tab_order: Vec::new(),
|
||||||
current_editor: 0,
|
current_editor: 0,
|
||||||
},
|
|
||||||
Some(path) => {
|
|
||||||
let tab_order = vec![path.to_string_lossy().to_string()];
|
|
||||||
Self {
|
|
||||||
editors: HashMap::from([(
|
|
||||||
tab_order.first().unwrap().to_owned(),
|
|
||||||
Editor::new(path),
|
|
||||||
)]),
|
|
||||||
tab_order,
|
|
||||||
current_editor: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user