rename shada to session

pull/9143/head
Ingrid 11 months ago
parent 2f13ad6360
commit 0fcb26c877

@ -15,7 +15,7 @@ static CONFIG_FILE: once_cell::sync::OnceCell<PathBuf> = once_cell::sync::OnceCe
static LOG_FILE: once_cell::sync::OnceCell<PathBuf> = once_cell::sync::OnceCell::new(); static LOG_FILE: once_cell::sync::OnceCell<PathBuf> = once_cell::sync::OnceCell::new();
static SHADA_FILE: once_cell::sync::OnceCell<PathBuf> = once_cell::sync::OnceCell::new(); static SESSION_FILE: once_cell::sync::OnceCell<PathBuf> = once_cell::sync::OnceCell::new();
pub fn initialize_config_file(specified_file: Option<PathBuf>) { pub fn initialize_config_file(specified_file: Option<PathBuf>) {
let config_file = specified_file.unwrap_or_else(default_config_file); let config_file = specified_file.unwrap_or_else(default_config_file);
@ -29,10 +29,10 @@ pub fn initialize_log_file(specified_file: Option<PathBuf>) {
LOG_FILE.set(log_file).ok(); LOG_FILE.set(log_file).ok();
} }
pub fn initialize_shada_file(specified_file: Option<PathBuf>) { pub fn initialize_session_file(specified_file: Option<PathBuf>) {
let shada_file = specified_file.unwrap_or_else(default_shada_file); let session_file = specified_file.unwrap_or_else(default_session_file);
ensure_parent_dir(&shada_file); ensure_parent_dir(&session_file);
SHADA_FILE.set(shada_file).ok(); SESSION_FILE.set(session_file).ok();
} }
/// A list of runtime directories from highest to lowest priority /// A list of runtime directories from highest to lowest priority
@ -156,8 +156,8 @@ pub fn log_file() -> PathBuf {
LOG_FILE.get().map(|path| path.to_path_buf()).unwrap() LOG_FILE.get().map(|path| path.to_path_buf()).unwrap()
} }
pub fn shada_file() -> PathBuf { pub fn session_file() -> PathBuf {
SHADA_FILE.get().map(|path| path.to_path_buf()).unwrap() SESSION_FILE.get().map(|path| path.to_path_buf()).unwrap()
} }
pub fn workspace_config_file() -> PathBuf { pub fn workspace_config_file() -> PathBuf {
@ -172,8 +172,8 @@ pub fn default_log_file() -> PathBuf {
cache_dir().join("helix.log") cache_dir().join("helix.log")
} }
pub fn default_shada_file() -> PathBuf { pub fn default_session_file() -> PathBuf {
state_dir().join("helix.shada") state_dir().join("helix.session")
} }
/// Merge two TOML documents, merging values from `right` onto `left` /// Merge two TOML documents, merging values from `right` onto `left`

@ -68,7 +68,7 @@ toml = "0.8"
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
# shada # session persistence
bincode = "2.0.0-rc.3" bincode = "2.0.0-rc.3"
# ripgrep for global search # ripgrep for global search

@ -27,7 +27,7 @@ use crate::{
handlers, handlers,
job::Jobs, job::Jobs,
keymap::Keymaps, keymap::Keymaps,
shada, session,
ui::{self, overlay::overlaid}, ui::{self, overlay::overlaid},
}; };
@ -1256,7 +1256,7 @@ impl Application {
} }
#[cfg(not(feature = "integration"))] #[cfg(not(feature = "integration"))]
shada::write_shada_file(); session::write_session_file();
errs errs
} }

@ -16,7 +16,7 @@ pub struct Args {
pub verbosity: u64, pub verbosity: u64,
pub log_file: Option<PathBuf>, pub log_file: Option<PathBuf>,
pub config_file: Option<PathBuf>, pub config_file: Option<PathBuf>,
pub shada_file: Option<PathBuf>, pub session_file: Option<PathBuf>,
pub files: Vec<(PathBuf, Position)>, pub files: Vec<(PathBuf, Position)>,
pub working_directory: Option<PathBuf>, pub working_directory: Option<PathBuf>,
} }
@ -62,9 +62,9 @@ impl Args {
Some(path) => args.log_file = Some(path.into()), Some(path) => args.log_file = Some(path.into()),
None => anyhow::bail!("--log must specify a path to write"), None => anyhow::bail!("--log must specify a path to write"),
}, },
"--shada" => match argv.next().as_deref() { "--session-file" => match argv.next().as_deref() {
Some(path) => args.shada_file = Some(path.into()), Some(path) => args.session_file = Some(path.into()),
None => anyhow::bail!("--shada must specify a path to write"), None => anyhow::bail!("--session-file must specify a path to write"),
}, },
"-w" | "--working-dir" => match argv.next().as_deref() { "-w" | "--working-dir" => match argv.next().as_deref() {
Some(path) => { Some(path) => {

@ -10,7 +10,7 @@ pub mod events;
pub mod health; pub mod health;
pub mod job; pub mod job;
pub mod keymap; pub mod keymap;
pub mod shada; pub mod session;
pub mod ui; pub mod ui;
use std::path::Path; use std::path::Path;

@ -63,7 +63,7 @@ FLAGS:
-v Increases logging verbosity each use for up to 3 times -v Increases logging verbosity each use for up to 3 times
--log <file> Specifies a file to use for logging --log <file> Specifies a file to use for logging
(default file: {}) (default file: {})
--shada <file> Specifies a file to use for shared data --session-file <file> Specifies a file to use for shared data
-V, --version Prints version information -V, --version Prints version information
--vsplit Splits all given files vertically into different windows --vsplit Splits all given files vertically into different windows
--hsplit Splits all given files horizontally into different windows --hsplit Splits all given files horizontally into different windows
@ -81,7 +81,7 @@ FLAGS:
helix_loader::initialize_config_file(args.config_file.clone()); helix_loader::initialize_config_file(args.config_file.clone());
helix_loader::initialize_log_file(args.log_file.clone()); helix_loader::initialize_log_file(args.log_file.clone());
helix_loader::initialize_shada_file(args.shada_file.clone()); helix_loader::initialize_session_file(args.session_file.clone());
// Help has a higher priority and should be handled separately. // Help has a higher priority and should be handled separately.
if args.display_help { if args.display_help {

@ -1,5 +1,5 @@
use bincode::{encode_into_std_write, Decode, Encode}; use bincode::{encode_into_std_write, Decode, Encode};
use helix_loader::{shada_file, VERSION_AND_GIT_HASH}; use helix_loader::{session_file, VERSION_AND_GIT_HASH};
// use helix_view::view::ViewPosition; // use helix_view::view::ViewPosition;
use std::{ use std::{
fs::File, fs::File,
@ -55,14 +55,14 @@ fn generate_header() -> Entry {
} }
} }
pub fn write_shada_file() { pub fn write_session_file() {
// TODO: merge existing file if exists // TODO: merge existing file if exists
// TODO: do something about this unwrap // TODO: do something about this unwrap
let mut shada_file = File::create(shada_file()).unwrap(); let mut session_file = File::create(session_file()).unwrap();
let header = generate_header(); let header = generate_header();
// TODO: do something about this unwrap // TODO: do something about this unwrap
encode_into_std_write(&header, &mut shada_file, bincode::config::standard()).unwrap(); encode_into_std_write(&header, &mut session_file, bincode::config::standard()).unwrap();
} }
Loading…
Cancel
Save