Fix tab change not redrawing text box
This commit is contained in:
parent
efe9302139
commit
22432e60b0
1 changed files with 15 additions and 9 deletions
24
src/main.rs
24
src/main.rs
|
|
@ -12,7 +12,7 @@ use cosmic::{
|
||||||
widget::{self, button, icon, nav_bar, segmented_button, view_switcher},
|
widget::{self, button, icon, nav_bar, segmented_button, view_switcher},
|
||||||
ApplicationExt, Element,
|
ApplicationExt, Element,
|
||||||
};
|
};
|
||||||
use cosmic_text::{FontSystem, SwashCache, SyntaxSystem, ViMode};
|
use cosmic_text::{Edit, FontSystem, SwashCache, SyntaxSystem, ViMode};
|
||||||
use std::{
|
use std::{
|
||||||
env, fs,
|
env, fs,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
|
@ -228,7 +228,8 @@ impl App {
|
||||||
match expand_opt {
|
match expand_opt {
|
||||||
Some(id) => {
|
Some(id) => {
|
||||||
//TODO: can this be optimized?
|
//TODO: can this be optimized?
|
||||||
cosmic::Application::on_nav_select(self, id);
|
// Command not used becuase opening a folder just returns Command::none
|
||||||
|
let _ = cosmic::Application::on_nav_select(self, id);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
break;
|
break;
|
||||||
|
|
@ -241,11 +242,16 @@ impl App {
|
||||||
self.nav_model.activate(active_id);
|
self.nav_model.activate(active_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_title(&mut self) -> Command<Message> {
|
// Call this any time the tab changes
|
||||||
|
pub fn update_tab(&mut self) -> Command<Message> {
|
||||||
self.update_nav_bar_active();
|
self.update_nav_bar_active();
|
||||||
|
|
||||||
let title = match self.active_tab() {
|
let title = match self.active_tab() {
|
||||||
Some(tab) => tab.title(),
|
Some(tab) => {
|
||||||
|
// Hack to ensure redraw on changing tabs
|
||||||
|
tab.editor.lock().unwrap().buffer_mut().set_redraw(true);
|
||||||
|
tab.title()
|
||||||
|
}
|
||||||
None => format!("No Open File"),
|
None => format!("No Open File"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -309,7 +315,7 @@ impl cosmic::Application for App {
|
||||||
app.open_tab(None);
|
app.open_tab(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
let command = app.update_title();
|
let command = app.update_tab();
|
||||||
(app, command)
|
(app, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -386,7 +392,7 @@ impl cosmic::Application for App {
|
||||||
}
|
}
|
||||||
Message::New => {
|
Message::New => {
|
||||||
self.open_tab(None);
|
self.open_tab(None);
|
||||||
return self.update_title();
|
return self.update_tab();
|
||||||
}
|
}
|
||||||
Message::OpenFileDialog => {
|
Message::OpenFileDialog => {
|
||||||
return Command::perform(
|
return Command::perform(
|
||||||
|
|
@ -402,7 +408,7 @@ impl cosmic::Application for App {
|
||||||
}
|
}
|
||||||
Message::OpenFile(path) => {
|
Message::OpenFile(path) => {
|
||||||
self.open_tab(Some(path));
|
self.open_tab(Some(path));
|
||||||
return self.update_title();
|
return self.update_tab();
|
||||||
}
|
}
|
||||||
Message::OpenProjectDialog => {
|
Message::OpenProjectDialog => {
|
||||||
return Command::perform(
|
return Command::perform(
|
||||||
|
|
@ -442,7 +448,7 @@ impl cosmic::Application for App {
|
||||||
}
|
}
|
||||||
Message::TabActivate(entity) => {
|
Message::TabActivate(entity) => {
|
||||||
self.tab_model.activate(entity);
|
self.tab_model.activate(entity);
|
||||||
return self.update_title();
|
return self.update_tab();
|
||||||
}
|
}
|
||||||
Message::TabClose(entity) => {
|
Message::TabClose(entity) => {
|
||||||
// Activate closest item
|
// Activate closest item
|
||||||
|
|
@ -462,7 +468,7 @@ impl cosmic::Application for App {
|
||||||
self.open_tab(None);
|
self.open_tab(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.update_title();
|
return self.update_tab();
|
||||||
}
|
}
|
||||||
Message::Todo => {
|
Message::Todo => {
|
||||||
log::warn!("TODO");
|
log::warn!("TODO");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue