reload explorer after file change in it

This commit is contained in:
Dongdong Zhou 2022-07-21 19:18:46 +01:00
parent c3bcc13172
commit 1008682d28
2 changed files with 15 additions and 4 deletions

View File

@ -647,7 +647,10 @@ fn event(
menu = menu.entry(item); menu = menu.entry(item);
} }
ctx.show_context_menu::<LapceData>(menu, mouse_event.pos); ctx.show_context_menu::<LapceData>(
menu,
ctx.to_window(mouse_event.pos),
);
} }
} }
} }

View File

@ -1469,6 +1469,7 @@ fn handle_event(
let path_c = path.clone(); let path_c = path.clone();
let event_sink = ctx.get_external_handle(); let event_sink = ctx.get_external_handle();
let tab_id = data.id; let tab_id = data.id;
let explorer = data.file_explorer.clone();
data.proxy.create_file( data.proxy.create_file(
path, path,
Box::new(move |res| { Box::new(move |res| {
@ -1488,14 +1489,16 @@ fn handle_event(
); );
} }
} }
explorer.reload();
}), }),
); );
ctx.set_handled(); ctx.set_handled();
} }
LapceUICommand::CreateDirectory { path } => { LapceUICommand::CreateDirectory { path } => {
let explorer = data.file_explorer.clone();
data.proxy.create_directory( data.proxy.create_directory(
path, path,
Box::new(|res| { Box::new(move |res| {
if let Err(err) = res { if let Err(err) = res {
// TODO: Inform the user through a corner-notif // TODO: Inform the user through a corner-notif
log::warn!( log::warn!(
@ -1503,30 +1506,35 @@ fn handle_event(
err err
); );
} }
explorer.reload();
}), }),
); );
ctx.set_handled(); ctx.set_handled();
} }
LapceUICommand::RenamePath { from, to } => { LapceUICommand::RenamePath { from, to } => {
let explorer = data.file_explorer.clone();
data.proxy.rename_path( data.proxy.rename_path(
from, from,
to, to,
Box::new(|res| { Box::new(move |res| {
if let Err(err) = res { if let Err(err) = res {
// TODO: inform the user through a corner-notif // TODO: inform the user through a corner-notif
log::warn!("Failed to rename path: {:?}", err); log::warn!("Failed to rename path: {:?}", err);
} }
explorer.reload();
}), }),
); );
} }
LapceUICommand::TrashPath { path } => { LapceUICommand::TrashPath { path } => {
let explorer = data.file_explorer.clone();
data.proxy.trash_path( data.proxy.trash_path(
path, path,
Box::new(|res| { Box::new(move |res| {
if let Err(err) = res { if let Err(err) = res {
// TODO: inform the user through a corner-notif // TODO: inform the user through a corner-notif
log::warn!("Failed to trash path: {:?}", err); log::warn!("Failed to trash path: {:?}", err);
} }
explorer.reload();
}), }),
); );
ctx.set_handled(); ctx.set_handled();