move to tab if file already open
This commit is contained in:
parent
94ef5675b7
commit
fa2104b9de
|
@ -172,6 +172,14 @@ impl Calcifer {
|
|||
}
|
||||
|
||||
pub fn open_file(&mut self, path_option: Option<&Path>) {
|
||||
if let Some(path) = path_option.clone() {
|
||||
for (index, tab) in self.tabs.clone().iter().enumerate() {
|
||||
if tab.path == path {
|
||||
self.selected_tab = tools::TabNumber::from_index(index);
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if self.tabs.len() < MAX_TABS {
|
||||
if let Some(path) = path_option {
|
||||
self.tabs.push(tools::Tab::new(path.to_path_buf()));
|
||||
|
|
|
@ -57,8 +57,6 @@ impl Tab {
|
|||
.and_then(|ext| ext.to_str())
|
||||
.unwrap_or_default();
|
||||
|
||||
println!("language : {}", extension);
|
||||
|
||||
Self {
|
||||
path: file_path.clone(),
|
||||
code: text,
|
||||
|
|
Loading…
Reference in a new issue