Implementing persistence for the terminal working directory, found an issue with my current data model. :(

This commit is contained in:
Mikayla Maki 2022-11-19 15:14:13 -08:00
parent cb1d2cd1f2
commit a8ed95e1dc
10 changed files with 113 additions and 21 deletions

View file

@ -1,4 +1,5 @@
pub mod mappings;
mod persistence;
pub mod terminal_container_view;
pub mod terminal_element;
pub mod terminal_view;
@ -32,9 +33,11 @@ use mappings::mouse::{
alt_scroll, grid_point, mouse_button_report, mouse_moved_report, mouse_side, scroll_report,
};
use persistence::TERMINAL_CONNECTION;
use procinfo::LocalProcessInfo;
use settings::{AlternateScroll, Settings, Shell, TerminalBlink};
use util::ResultExt;
use workspace::{ItemId, WorkspaceId};
use std::{
cmp::min,
@ -281,6 +284,8 @@ impl TerminalBuilder {
blink_settings: Option<TerminalBlink>,
alternate_scroll: &AlternateScroll,
window_id: usize,
item_id: ItemId,
workspace_id: WorkspaceId,
) -> Result<TerminalBuilder> {
let pty_config = {
let alac_shell = shell.clone().and_then(|shell| match shell {
@ -385,6 +390,8 @@ impl TerminalBuilder {
last_mouse_position: None,
next_link_id: 0,
selection_phase: SelectionPhase::Ended,
workspace_id,
item_id,
};
Ok(TerminalBuilder {
@ -528,6 +535,8 @@ pub struct Terminal {
scroll_px: f32,
next_link_id: usize,
selection_phase: SelectionPhase,
item_id: ItemId,
workspace_id: WorkspaceId,
}
impl Terminal {
@ -567,7 +576,17 @@ impl Terminal {
cx.emit(Event::Wakeup);
if self.update_process_info() {
cx.emit(Event::TitleChanged)
cx.emit(Event::TitleChanged);
if let Some(foreground_info) = self.foreground_process_info {
cx.background().spawn(async move {
TERMINAL_CONNECTION.save_working_directory(
self.item_id,
&self.workspace_id,
&foreground_info.cwd,
);
});
}
}
}
AlacTermEvent::ColorRequest(idx, fun_ptr) => {