mirror of
https://github.com/sxyazi/yazi.git
synced 2025-01-06 08:03:38 +03:00
fix: resize isn't triggered on app restoring (#483)
This commit is contained in:
parent
72f924b9e5
commit
1908ff2047
@ -23,7 +23,7 @@ impl Tab {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if hovered != &opt.lock.url {
|
if opt.lock.url != *hovered {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ impl App {
|
|||||||
Event::Call(exec, layer) => app.dispatch_call(exec, layer),
|
Event::Call(exec, layer) => app.dispatch_call(exec, layer),
|
||||||
Event::Render => render_in_place = true,
|
Event::Render => render_in_place = true,
|
||||||
Event::Key(key) => app.dispatch_key(key),
|
Event::Key(key) => app.dispatch_key(key),
|
||||||
Event::Resize(cols, rows) => app.dispatch_resize(cols, rows)?,
|
Event::Resize => app.resize()?,
|
||||||
Event::Paste(str) => app.dispatch_paste(str),
|
Event::Paste(str) => app.dispatch_paste(str),
|
||||||
Event::Quit(no_cwd_file) => {
|
Event::Quit(no_cwd_file) => {
|
||||||
app.quit(no_cwd_file)?;
|
app.quit(no_cwd_file)?;
|
||||||
@ -65,15 +65,6 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch_resize(&mut self, _: u16, _: u16) -> Result<()> {
|
|
||||||
self.cx.manager.active_mut().preview.reset();
|
|
||||||
self.render()?;
|
|
||||||
|
|
||||||
self.cx.manager.current_mut().sync_page(true);
|
|
||||||
self.cx.manager.peek(false);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn dispatch_call(&mut self, exec: Vec<Exec>, layer: Layer) {
|
fn dispatch_call(&mut self, exec: Vec<Exec>, layer: Layer) {
|
||||||
Executor::new(self).dispatch(&exec, layer);
|
Executor::new(self).dispatch(&exec, layer);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
mod plugin;
|
mod plugin;
|
||||||
mod quit;
|
mod quit;
|
||||||
mod render;
|
mod render;
|
||||||
|
mod resize;
|
||||||
mod stop;
|
mod stop;
|
||||||
|
14
yazi-fm/src/app/commands/resize.rs
Normal file
14
yazi-fm/src/app/commands/resize.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
use crate::app::App;
|
||||||
|
|
||||||
|
impl App {
|
||||||
|
pub(crate) fn resize(&mut self) -> Result<()> {
|
||||||
|
self.cx.manager.active_mut().preview.reset();
|
||||||
|
self.render()?;
|
||||||
|
|
||||||
|
self.cx.manager.current_mut().sync_page(true);
|
||||||
|
self.cx.manager.hover(None);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
@ -27,10 +27,10 @@ impl App {
|
|||||||
} else {
|
} else {
|
||||||
self.term = Some(Term::start().unwrap());
|
self.term = Some(Term::start().unwrap());
|
||||||
self.signals.stop_term(false);
|
self.signals.stop_term(false);
|
||||||
// FIXME: find a better way to handle this
|
|
||||||
self.render().unwrap();
|
// While the app resumes, it's possible that the terminal size has changed.
|
||||||
self.cx.manager.hover(None);
|
// We need to trigger a resize, and render the UI based on the resized area.
|
||||||
self.cx.manager.peek(true);
|
self.resize().unwrap();
|
||||||
}
|
}
|
||||||
if let Some(tx) = opt.tx {
|
if let Some(tx) = opt.tx {
|
||||||
tx.send(()).ok();
|
tx.send(()).ok();
|
||||||
|
@ -88,7 +88,7 @@ impl Signals {
|
|||||||
// otherwise event will be dispatched twice.
|
// otherwise event will be dispatched twice.
|
||||||
CrosstermEvent::Key(key @ KeyEvent { kind: KeyEventKind::Press, .. }) => Event::Key(key),
|
CrosstermEvent::Key(key @ KeyEvent { kind: KeyEventKind::Press, .. }) => Event::Key(key),
|
||||||
CrosstermEvent::Paste(str) => Event::Paste(str),
|
CrosstermEvent::Paste(str) => Event::Paste(str),
|
||||||
CrosstermEvent::Resize(cols, rows) => Event::Resize(cols, rows),
|
CrosstermEvent::Resize(..) => Event::Resize,
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
if tx.send(event).is_err() {
|
if tx.send(event).is_err() {
|
||||||
|
@ -22,7 +22,8 @@ impl Loader {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let b = fs::read(BOOT.plugin_dir.join(name)).await.map(|v| v.into()).or_else(|_| {
|
let path = BOOT.plugin_dir.join(format!("{name}.yazi/init.lua"));
|
||||||
|
let b = fs::read(path).await.map(|v| v.into()).or_else(|_| {
|
||||||
Ok(Cow::from(match name {
|
Ok(Cow::from(match name {
|
||||||
"noop.lua" => include_bytes!("../preset/plugins/noop.lua") as &[u8],
|
"noop.lua" => include_bytes!("../preset/plugins/noop.lua") as &[u8],
|
||||||
"archive.lua" => include_bytes!("../preset/plugins/archive.lua"),
|
"archive.lua" => include_bytes!("../preset/plugins/archive.lua"),
|
||||||
|
@ -33,7 +33,7 @@ pub fn init() {
|
|||||||
fn stage_2(lua: &Lua) {
|
fn stage_2(lua: &Lua) {
|
||||||
let setup = br#"
|
let setup = br#"
|
||||||
ya.SYNC_ON = true
|
ya.SYNC_ON = true
|
||||||
package.path = BOOT.plugin_dir .. "/?.yazi/init.lua;" .. BOOT.plugin_dir .. "/?.lua;" .. package.path
|
package.path = BOOT.plugin_dir .. "/?.yazi/init.lua;" .. package.path
|
||||||
"#;
|
"#;
|
||||||
lua.load(setup as &[u8]).exec().unwrap();
|
lua.load(setup as &[u8]).exec().unwrap();
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ pub enum Event {
|
|||||||
Call(Vec<Exec>, Layer),
|
Call(Vec<Exec>, Layer),
|
||||||
Render,
|
Render,
|
||||||
Key(KeyEvent),
|
Key(KeyEvent),
|
||||||
Resize(u16, u16),
|
Resize,
|
||||||
Paste(String),
|
Paste(String),
|
||||||
Quit(bool), // no-cwd-file
|
Quit(bool), // no-cwd-file
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user