rename shada to session

This commit is contained in:
Ingrid 2023-12-28 17:33:08 +01:00
parent 2f13ad6360
commit 0fcb26c877
7 changed files with 23 additions and 23 deletions

View File

@ -15,7 +15,7 @@
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>) {
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();
}
pub fn initialize_shada_file(specified_file: Option<PathBuf>) {
let shada_file = specified_file.unwrap_or_else(default_shada_file);
ensure_parent_dir(&shada_file);
SHADA_FILE.set(shada_file).ok();
pub fn initialize_session_file(specified_file: Option<PathBuf>) {
let session_file = specified_file.unwrap_or_else(default_session_file);
ensure_parent_dir(&session_file);
SESSION_FILE.set(session_file).ok();
}
/// 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()
}
pub fn shada_file() -> PathBuf {
SHADA_FILE.get().map(|path| path.to_path_buf()).unwrap()
pub fn session_file() -> PathBuf {
SESSION_FILE.get().map(|path| path.to_path_buf()).unwrap()
}
pub fn workspace_config_file() -> PathBuf {
@ -172,8 +172,8 @@ pub fn default_log_file() -> PathBuf {
cache_dir().join("helix.log")
}
pub fn default_shada_file() -> PathBuf {
state_dir().join("helix.shada")
pub fn default_session_file() -> PathBuf {
state_dir().join("helix.session")
}
/// Merge two TOML documents, merging values from `right` onto `left`

View File

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

View File

@ -27,7 +27,7 @@
handlers,
job::Jobs,
keymap::Keymaps,
shada,
session,
ui::{self, overlay::overlaid},
};
@ -1256,7 +1256,7 @@ pub async fn close(&mut self) -> Vec<anyhow::Error> {
}
#[cfg(not(feature = "integration"))]
shada::write_shada_file();
session::write_session_file();
errs
}

View File

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

View File

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

View File

@ -63,7 +63,7 @@ async fn main_impl() -> Result<i32> {
-v Increases logging verbosity each use for up to 3 times
--log <file> Specifies a file to use for logging
(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
--vsplit Splits all given files vertically into different windows
--hsplit Splits all given files horizontally into different windows
@ -81,7 +81,7 @@ async fn main_impl() -> Result<i32> {
helix_loader::initialize_config_file(args.config_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.
if args.display_help {

View File

@ -1,5 +1,5 @@
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 std::{
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: 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();
// 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();
}